Class: Solis::HasMany

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

Instance Method Summary collapse

Instance Method Details

#children_for(parent, map) ⇒ Object



304
305
306
# File 'lib/solis/sparql_adaptor.rb', line 304

def children_for(parent, map)
  map.values.flatten
end

#inverse_filterObject



289
290
291
# File 'lib/solis/sparql_adaptor.rb', line 289

def inverse_filter
  @inverse_filter || foreign_key
end


308
309
310
# File 'lib/solis/sparql_adaptor.rb', line 308

def link_filter(parents)
  {inverse_filter => parent_filter(parents)}
end

#load_params(parents, query) ⇒ Object



293
294
295
296
297
298
299
300
301
302
# File 'lib/solis/sparql_adaptor.rb', line 293

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