Module: ActiveFedora::Calculations

Included in:
Relation
Defined in:
lib/active_fedora/relation/calculations.rb

Instance Method Summary collapse

Instance Method Details

#calculate(calculation, conditions, opts = {}) ⇒ Object


15
16
17
# File 'lib/active_fedora/relation/calculations.rb', line 15

def calculate(calculation, conditions, opts={})
  SolrService.query(create_query(conditions), :raw=>true, :rows=>0)['response']['numFound']
end

#count(*args) ⇒ Object

Get a count of the number of objects from solr Takes :conditions as an argument


6
7
8
9
10
11
12
13
# File 'lib/active_fedora/relation/calculations.rb', line 6

def count(*args)
  return apply_finder_options(args.first).count  if args.any?
  opts = {}
  opts[:rows] = limit_value if limit_value
  opts[:sort] = order_values if order_values
  
  calculate :count, where_values, opts
end