Class: HashSerializer::Attribute

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ Attribute

Returns a new instance of Attribute.



5
6
7
8
# File 'lib/hash_serializer/attribute.rb', line 5

def initialize(name, options = {})
  @name = name
  @options = options
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/hash_serializer/attribute.rb', line 3

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/hash_serializer/attribute.rb', line 3

def options
  @options
end

Instance Method Details

#key_nameObject



10
11
12
# File 'lib/hash_serializer/attribute.rb', line 10

def key_name
  options[:as] || name
end