Class: Ivy::Serializers::Attribute
- Inherits:
-
Object
- Object
- Ivy::Serializers::Attribute
- Defined in:
- lib/ivy/serializers/attribute.rb
Instance Method Summary collapse
- #generate(generator, resource) ⇒ Object
-
#initialize(name, &getter) ⇒ Attribute
constructor
A new instance of Attribute.
Constructor Details
#initialize(name, &getter) ⇒ Attribute
Returns a new instance of Attribute.
4 5 6 7 |
# File 'lib/ivy/serializers/attribute.rb', line 4 def initialize(name, &getter) @name = name @getter = getter || method(:default_getter) end |
Instance Method Details
#generate(generator, resource) ⇒ Object
9 10 11 |
# File 'lib/ivy/serializers/attribute.rb', line 9 def generate(generator, resource) generator.attribute(@name, get(resource)) end |