Class: Deserializer::Attribute::Attribute
- Inherits:
-
Object
- Object
- Deserializer::Attribute::Attribute
- Defined in:
- lib/deserializer/attribute/attribute.rb
Instance Method Summary collapse
-
#initialize(type, name, opts) ⇒ Attribute
constructor
A new instance of Attribute.
- #key ⇒ Object
- #to_hash(params, object) ⇒ Object
Constructor Details
#initialize(type, name, opts) ⇒ Attribute
Returns a new instance of Attribute.
4 5 6 7 8 |
# File 'lib/deserializer/attribute/attribute.rb', line 4 def initialize( type, name, opts ) @type = type @name = name @opts = opts end |
Instance Method Details
#key ⇒ Object
10 11 12 |
# File 'lib/deserializer/attribute/attribute.rb', line 10 def key @opts.fetch :key, @name end |
#to_hash(params, object) ⇒ Object
14 15 16 17 |
# File 'lib/deserializer/attribute/attribute.rb', line 14 def to_hash( params, object ) attribute = @type.new( @name, @opts, object ) attribute.to_hash( params ) end |