Class: Teamtailor::Relationship
- Inherits:
-
Object
- Object
- Teamtailor::Relationship
- Defined in:
- lib/teamtailor/relationship.rb
Instance Method Summary collapse
-
#initialize(relation_name, relationships = {}, included = {}) ⇒ Relationship
constructor
A new instance of Relationship.
- #loaded? ⇒ Boolean
- #records ⇒ Object
Constructor Details
#initialize(relation_name, relationships = {}, included = {}) ⇒ Relationship
Returns a new instance of Relationship.
5 6 7 8 9 |
# File 'lib/teamtailor/relationship.rb', line 5 def initialize(relation_name, relationships = {}, included = {}) @relation_name = relation_name @relationships = relationships @included = included end |
Instance Method Details
#loaded? ⇒ Boolean
11 12 13 |
# File 'lib/teamtailor/relationship.rb', line 11 def loaded? !record_ids.empty? end |
#records ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/teamtailor/relationship.rb', line 15 def records raise Teamtailor::UnloadedRelationError unless loaded? record_json = included.select do |k| record_ids.include?(k['id']) && k['type'] == record_type end Teamtailor::Parser.parse({ 'data' => record_json, 'included' => included }) end |