class Unchained::Client::Mixins::Resource::Attribute
An `Attribute` is what `attribute` creates.
Attributes
name[R]
opts[R]
type[R]
Public Class Methods
new(name, type, opts)
click to toggle source
# File lib/unchained/client/mixins/resource.rb, line 28 def initialize(name, type, opts) @name = name @type = type @opts = opts end
Public Instance Methods
allow_nil?()
click to toggle source
Whether or not to allow nil, defaults to false.
# File lib/unchained/client/mixins/resource.rb, line 49 def allow_nil? @opts.fetch(:allow_nil, false) end
expand_method()
click to toggle source
Some of the attributes can be expanded.
# File lib/unchained/client/mixins/resource.rb, line 54 def expand_method @opts.fetch(:expand, nil) end
json_field()
click to toggle source
The field that maps to this attribute in the JSON.
Usage:
# json_field will return 'FOO' attribute :foo, json: 'FOO' # json_field will return 'foo_bar' attribute :foo_bar
# File lib/unchained/client/mixins/resource.rb, line 44 def json_field @opts.fetch(:json, @name.to_s) end