Class: Lurch::Relationship::HasMany

Inherits:
Lurch::Relationship show all
Defined in:
lib/lurch/relationship/has_many.rb

Instance Attribute Summary

Attributes inherited from Lurch::Relationship

#data

Instance Method Summary collapse

Methods inherited from Lurch::Relationship

from_document, #loaded?, #method_missing, #respond_to_missing?

Constructor Details

#initialize(store, relationship_key, document) ⇒ HasMany

Returns a new instance of HasMany.



4
5
6
7
8
9
# File 'lib/lurch/relationship/has_many.rb', line 4

def initialize(store, relationship_key, document)
  @store = store
  @relationship_key = relationship_key
  @document = document
  @data = @document["data"].map { |resource_identifier| Resource.new(@store, resource_identifier["type"], resource_identifier["id"]) }
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Lurch::Relationship

Instance Method Details

#inspectObject



11
12
13
14
# File 'lib/lurch/relationship/has_many.rb', line 11

def inspect
  suffix = @data.first ? "[#{Inflector.classify(@data.first.type)}]" : ""
  "#<#{self.class}#{suffix} size: #{@data.size}>"
end