Module: ReputationSystem::FinderMethods::ClassMethods

Defined in:
lib/reputation_system/finder_methods.rb

Instance Method Summary collapse

Instance Method Details

#count_with_reputation(*args) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/reputation_system/finder_methods.rb', line 33

def count_with_reputation(*args)
  reputation_name, srn, find_scope, options = parse_query_args(*args)
  options[:joins] = build_join_statement(table_name, name, srn, options[:joins])
  options[:conditions] = build_condition_statement(options[:conditions])
  options[:conditions][0].gsub!(reputation_name.to_s, "COALESCE(rs_reputations.value, 0)")
  count(find_scope, options)
end

#find_with_normalized_reputation(*args) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/reputation_system/finder_methods.rb', line 41

def find_with_normalized_reputation(*args)
  reputation_name, srn, find_scope, options = parse_query_args(*args)
  options[:select] = build_select_statement(table_name, reputation_name, options[:select], srn, true)
  options[:joins] = build_join_statement(table_name, name, srn, options[:joins])
  options[:conditions] = build_condition_statement(options[:conditions])
  find(find_scope, options)
end

#find_with_reputation(*args) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/reputation_system/finder_methods.rb', line 25

def find_with_reputation(*args)
  reputation_name, srn, find_scope, options = parse_query_args(*args)
  options[:select] = build_select_statement(table_name, reputation_name, options[:select])
  options[:joins] = build_join_statement(table_name, name, srn, options[:joins])
  options[:conditions] = build_condition_statement(options[:conditions])
  find(find_scope, options)
end

#find_with_reputation_sql(*args) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/reputation_system/finder_methods.rb', line 49

def find_with_reputation_sql(*args)
  reputation_name, srn, find_scope, options = parse_query_args(*args)
  options[:select] = build_select_statement(table_name, reputation_name, options[:select])
  options[:joins] = build_join_statement(table_name, name, srn, options[:joins])
  options[:conditions] = build_condition_statement(options[:conditions])
  if respond_to?(:construct_finder_sql, true)
    construct_finder_sql(options)
  else
    construct_finder_arel(options).to_sql
  end
end