Class: Graphiti::Util::SerializerRelationships

Inherits:
Object
  • Object
show all
Defined in:
lib/graphiti/util/serializer_relationships.rb

Instance Method Summary collapse

Constructor Details

#initialize(resource_class, sideloads) ⇒ SerializerRelationships

Returns a new instance of SerializerRelationships.



4
5
6
7
8
# File 'lib/graphiti/util/serializer_relationships.rb', line 4

def initialize(resource_class, sideloads)
  @resource_class = resource_class
  @serializer = @resource_class.serializer
  @sideloads = sideloads
end

Instance Method Details

#applyObject



10
11
12
13
14
15
16
17
# File 'lib/graphiti/util/serializer_relationships.rb', line 10

def apply
  @sideloads.each_pair do |name, sideload|
    if apply?(sideload)
      SerializerRelationship
        .new(@resource_class, @serializer, sideload).apply
    end
  end
end