class Lurch::Relationship

Attributes

data[R]

Public Class Methods

from_document(store, relationship_key, document) click to toggle source
# File lib/lurch/relationship.rb, line 5
def self.from_document(store, relationship_key, document)
  return Relationship::HasMany.new(store, relationship_key, document) if document.key?("data") && document["data"].is_a?(Array)
  return Relationship::HasOne.new(store, relationship_key, document) if document.key?("data")
  return Relationship::Linked.new(store, relationship_key, document) if document.key?("links") && document["links"].key?("related")
  raise ArgumentError, "Invalid relationship document"
end

Public Instance Methods

loaded?() click to toggle source
# File lib/lurch/relationship.rb, line 12
def loaded?
  !!defined?(@data)
end
method_missing(method, *arguments, &block) click to toggle source
Calls superclass method
# File lib/lurch/relationship.rb, line 21
def method_missing(method, *arguments, &block)
  raise Errors::RelationshipNotLoaded, @relationship_key unless loaded?
  super
end
respond_to_missing?(method, all) click to toggle source
Calls superclass method
# File lib/lurch/relationship.rb, line 16
def respond_to_missing?(method, all)
  raise Errors::RelationshipNotLoaded, @relationship_key unless loaded?
  super
end