Class: RestPack::Serializer::Result
- Inherits:
-
Object
- Object
- RestPack::Serializer::Result
- Defined in:
- lib/restpack_serializer/result.rb
Instance Attribute Summary collapse
-
#links ⇒ Object
Returns the value of attribute links.
-
#meta ⇒ Object
Returns the value of attribute meta.
-
#resources ⇒ Object
Returns the value of attribute resources.
Instance Method Summary collapse
-
#initialize ⇒ Result
constructor
A new instance of Result.
- #serialize ⇒ Object
Constructor Details
#initialize ⇒ Result
Returns a new instance of Result.
5 6 7 8 9 |
# File 'lib/restpack_serializer/result.rb', line 5 def initialize @resources = {} @meta = {} @links = {} end |
Instance Attribute Details
#links ⇒ Object
Returns the value of attribute links.
3 4 5 |
# File 'lib/restpack_serializer/result.rb', line 3 def links @links end |
#meta ⇒ Object
Returns the value of attribute meta.
3 4 5 |
# File 'lib/restpack_serializer/result.rb', line 3 def @meta end |
#resources ⇒ Object
Returns the value of attribute resources.
3 4 5 |
# File 'lib/restpack_serializer/result.rb', line 3 def resources @resources end |
Instance Method Details
#serialize ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/restpack_serializer/result.rb', line 11 def serialize result = {} unless @resources.empty? inject_has_many_links! result[@resources.keys.first] = @resources.values.first linked = @resources.except(@resources.keys.first) result[:linked] = linked unless linked.empty? end result[:links] = @links unless @links.empty? result[:meta] = @meta unless @meta.empty? result end |