Class: Solis::BelongsTo

Inherits:
Graphiti::Sideload::BelongsTo
  • Object
show all
Defined in:
lib/solis/sparql_adaptor.rb

Instance Method Summary collapse

Instance Method Details

#load_params(parents, query) ⇒ Object



250
251
252
253
254
255
256
257
258
259
# File 'lib/solis/sparql_adaptor.rb', line 250

def load_params(parents, query)
  query.hash.tap do |hash|
    hash[:filter] ||= {}
    unless hash[:filter].include?(:id)
      all_ids = parents.map{|m| m.instance_variable_get("@#{query.association_name.to_s}")}.flatten.map{|m| m.instance_variable_get("@#{primary_key}")}.uniq.compact.join(',')

      hash[:filter].merge!({primary_key => all_ids})
    end
  end
end