Class: MotionJsonApi::Resources
- Inherits:
-
Object
- Object
- MotionJsonApi::Resources
- Defined in:
- lib/motion-json-api/resources.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#links ⇒ Object
Returns the value of attribute links.
Instance Method Summary collapse
-
#initialize(object, top_level, included) ⇒ Resources
constructor
A new instance of Resources.
Constructor Details
#initialize(object, top_level, included) ⇒ Resources
Returns a new instance of Resources.
6 7 8 9 10 11 12 |
# File 'lib/motion-json-api/resources.rb', line 6 def initialize(object, top_level, included) @links = object.fetch("links", {}) @data = object["data"].map do |data| resource_klass = Resource._klass_for_type(data["type"]) resource_klass.new({"data" => data, "links" => data.fetch("links", {})}, top_level, included) end end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
4 5 6 |
# File 'lib/motion-json-api/resources.rb', line 4 def data @data end |
#links ⇒ Object
Returns the value of attribute links.
3 4 5 |
# File 'lib/motion-json-api/resources.rb', line 3 def links @links end |