Class: SerializationSelectorDsl
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- SerializationSelectorDsl
- Defined in:
- lib/media_types/serialization.rb
Instance Attribute Summary collapse
-
#matched ⇒ Object
Returns the value of attribute matched.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(controller, selected_serializer) ⇒ SerializationSelectorDsl
constructor
A new instance of SerializationSelectorDsl.
- #serializer(klazz, obj = nil, &block) ⇒ Object
Constructor Details
#initialize(controller, selected_serializer) ⇒ SerializationSelectorDsl
Returns a new instance of SerializationSelectorDsl.
26 27 28 29 30 31 |
# File 'lib/media_types/serialization.rb', line 26 def initialize(controller, selected_serializer) @serializer = selected_serializer self.value = nil self.matched = false super controller end |
Instance Attribute Details
#matched ⇒ Object
Returns the value of attribute matched.
33 34 35 |
# File 'lib/media_types/serialization.rb', line 33 def matched @matched end |
#value ⇒ Object
Returns the value of attribute value.
33 34 35 |
# File 'lib/media_types/serialization.rb', line 33 def value @value end |
Instance Method Details
#serializer(klazz, obj = nil, &block) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/media_types/serialization.rb', line 35 def serializer(klazz, obj = nil, &block) return if klazz != @serializer self.matched = true self.value = block.nil? ? obj : yield end |