Class: RSpecJSONAPISerializer::Metadata::Relationships

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec_jsonapi_serializer/metadata/relationships.rb

Instance Method Summary collapse

Constructor Details

#initialize(serializer) ⇒ Relationships

Returns a new instance of Relationships.



9
10
11
# File 'lib/rspec_jsonapi_serializer/metadata/relationships.rb', line 9

def initialize(serializer)
  @serializer = serializer
end

Instance Method Details

#relationship(key) ⇒ Object



13
14
15
# File 'lib/rspec_jsonapi_serializer/metadata/relationships.rb', line 13

def relationship(key)
  relationships.values.find { |relationship| relationship.key.to_s == key.to_s }
end

#relationshipsObject



17
18
19
# File 'lib/rspec_jsonapi_serializer/metadata/relationships.rb', line 17

def relationships
  serializer.class&.relationships_to_serialize || {}
end