Class: MotionJsonApi::Resources

Inherits:
Object
  • Object
show all
Defined in:
lib/motion-json-api/resources.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#dataObject

Returns the value of attribute data.



4
5
6
# File 'lib/motion-json-api/resources.rb', line 4

def data
  @data
end

Returns the value of attribute links.



3
4
5
# File 'lib/motion-json-api/resources.rb', line 3

def links
  @links
end