Class: Subjoin::Relationship
- Inherits:
-
Object
- Object
- Subjoin::Relationship
- Defined in:
- lib/subjoin/relationship.rb
Overview
A related resource link, providing access to resource objects linked in a relationship
Instance Attribute Summary collapse
-
#linkages ⇒ Object
readonly
Returns the value of attribute linkages.
-
#links ⇒ Object
readonly
Returns the value of attribute links.
Attributes included from Metable
Instance Method Summary collapse
-
#initialize(data, doc) ⇒ Relationship
constructor
A new instance of Relationship.
-
#lookup ⇒ Array<Subjoin::Resource>
Resolve available linkages and return related resources.
Methods included from Metable
Methods included from Linkable
Constructor Details
#initialize(data, doc) ⇒ Relationship
10 11 12 13 14 15 |
# File 'lib/subjoin/relationship.rb', line 10 def initialize(data, doc) @document = doc @links = load_links(data['links']) @linkages = load_linkages(data['data'], doc) = (data['meta']) end |
Instance Attribute Details
#linkages ⇒ Object (readonly)
Returns the value of attribute linkages.
9 10 11 |
# File 'lib/subjoin/relationship.rb', line 9 def linkages @linkages end |
#links ⇒ Object (readonly)
Returns the value of attribute links.
9 10 11 |
# File 'lib/subjoin/relationship.rb', line 9 def links @links end |
Instance Method Details
#lookup ⇒ Array<Subjoin::Resource>
Resolve available linkages and return related resources
19 20 21 22 |
# File 'lib/subjoin/relationship.rb', line 19 def lookup return [] unless @document.has_included? @linkages.map{|l| @document.included[l]} end |