Class: Eazypi::Serializer::Attribute

Inherits:
Object
  • Object
show all
Defined in:
lib/eazypi/serializer.rb

Overview

Defines an Attribute on a serializer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type:, required:, method:, method_name:) ⇒ Attribute

Returns a new instance of Attribute.



12
13
14
15
16
17
18
# File 'lib/eazypi/serializer.rb', line 12

def initialize(name, type:, required:, method:, method_name:)
  @name = name
  @type = type
  @method = method
  @method_name = method_name
  @required = required
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/eazypi/serializer.rb', line 10

def name
  @name
end

#requiredObject (readonly)

Returns the value of attribute required.



10
11
12
# File 'lib/eazypi/serializer.rb', line 10

def required
  @required
end

#typeObject (readonly)

Returns the value of attribute type.



10
11
12
# File 'lib/eazypi/serializer.rb', line 10

def type
  @type
end

Instance Method Details

#serialize(object) ⇒ Object



20
21
22
23
24
# File 'lib/eazypi/serializer.rb', line 20

def serialize(object)
  the_value = value(object)

  Serializer.serialize_object(type, the_value)
end