Class: Deserializer::Attribute::Attribute

Inherits:
Object
  • Object
show all
Defined in:
lib/deserializer/attribute/attribute.rb

Instance Method Summary collapse

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

#keyObject



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