Class: Lurch::Relationship::Linked

Inherits:
Lurch::Relationship show all
Defined in:
lib/lurch/relationship/linked.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) ⇒ Linked

Returns a new instance of Linked.



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

def initialize(store, relationship_key, document)
  @store = store
  @relationship_key = relationship_key
  @href = document["links"]["related"]
end

Dynamic Method Handling

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

Instance Method Details

#fetchObject



10
11
12
# File 'lib/lurch/relationship/linked.rb', line 10

def fetch
  @data = @store.load_from_url(@href)
end

#inspectObject

def filter(*args)

@store.query.link(@href).filter(*args)

end

def include(*args)

@store.query.link(@href).include(*args)

end

def fields(*args)

@store.query.link(@href).fields(*args)

end

def sort(*args)

@store.query.link(@href).sort(*args)

end

def page(*args)

@store.query.link(@href).page(*args)

end



34
35
36
37
# File 'lib/lurch/relationship/linked.rb', line 34

def inspect
  suffix = loaded? ? " \"loaded\"" : ""
  "#<#{self.class} href: #{@href.inspect}#{suffix}>"
end