Class: Graphiti::Sideload::HasMany
Constant Summary
HOOK_ACTIONS, TYPES
Instance Attribute Summary
#group_name, #link, #name, #parent, #parent_resource_class, #polymorphic_as
Instance Method Summary
collapse
after_save, #always_include_resource_ids?, assign, #assign, #assign_each, assign_each, #associate, #associate_all, #association_name, #base_scope, #build_resource_proxy, #clear_resources, #create_remote_resource, #description, #disassociate, #errors, #fire_hooks!, #foreign_key, hooks, #ids_for_parents, #infer_foreign_key, link, #link?, #link_extra_fields, #load, params, #parent_resource, #performant_assign?, #polymorphic_child?, #polymorphic_has_many?, #polymorphic_has_one?, #polymorphic_parent?, pre_load, #primary_key, #readable?, #remote?, #resolve, #resource, #resource_class, #resource_class_loaded?, #scope, scope, #shared_remote?, #single?, #writable?
Constructor Details
#initialize(name, opts) ⇒ HasMany
Returns a new instance of HasMany.
2
3
4
5
6
|
# File 'lib/graphiti/sideload/has_many.rb', line 2
def initialize(name, opts)
@inverse_filter = opts[:inverse_filter]
super(name, opts)
end
|
Instance Method Details
#base_filter(parents) ⇒ Object
23
24
25
|
# File 'lib/graphiti/sideload/has_many.rb', line 23
def base_filter(parents)
{foreign_key => parent_filter(parents)}
end
|
#inverse_filter ⇒ Object
12
13
14
|
# File 'lib/graphiti/sideload/has_many.rb', line 12
def inverse_filter
@inverse_filter || foreign_key
end
|
#link_filter(parents) ⇒ Object
27
28
29
|
# File 'lib/graphiti/sideload/has_many.rb', line 27
def link_filter(parents)
{inverse_filter => parent_filter(parents)}
end
|
#load_params(parents, query) ⇒ Object
16
17
18
19
20
21
|
# File 'lib/graphiti/sideload/has_many.rb', line 16
def load_params(parents, query)
query.hash.tap do |hash|
hash[:filter] ||= {}
hash[:filter].merge!(base_filter(parents))
end
end
|
8
9
10
|
# File 'lib/graphiti/sideload/has_many.rb', line 8
def type
:has_many
end
|