Module: Graphiti::ActiveGraph::Resource

Defined in:
lib/graphiti/active_graph/resource.rb,
lib/graphiti/active_graph/resource/persistence.rb

Defined Under Namespace

Modules: Persistence

Instance Method Summary collapse

Instance Method Details

#all_with_preloaded(obj_arr, params) ⇒ Object



22
23
24
25
26
27
# File 'lib/graphiti/active_graph/resource.rb', line 22

def all_with_preloaded(obj_arr, params)
  validate!(params)

  runner = ::Graphiti::Runner.new(self, params)
  runner.proxy(nil, raise_on_missing: false, preloaded: obj_arr)
end

#guard_nil_id!(params) ⇒ Object



29
30
# File 'lib/graphiti/active_graph/resource.rb', line 29

def guard_nil_id!(params)
end

#relation_resource?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/graphiti/active_graph/resource.rb', line 4

def relation_resource?
  config[:relation_resource] || false
end

#relationship_resource=(value) ⇒ Object



8
9
10
# File 'lib/graphiti/active_graph/resource.rb', line 8

def relationship_resource=(value)
  config[:relation_resource] = value
end

#with_preloaded_obj(obj, params) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/graphiti/active_graph/resource.rb', line 12

def with_preloaded_obj(obj, params)
  id = params[:data].try(:[], :id) || params.delete(:id)
  params[:filter] ||= {}
  params[:filter][:id] = id if id

  validate!(params)
  runner = ::Graphiti::Runner.new(self, params)
  runner.proxy(nil, single: true, raise_on_missing: false, preloaded: obj, bypass_required_filters: true)
end