Class: ReputationSystem::Evaluation

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/reputation_system/models/evaluation.rb

Class Method Summary collapse

Class Method Details

.create_evaluation(reputation_name, value, source, target) ⇒ Object



45
46
47
48
49
# File 'lib/reputation_system/models/evaluation.rb', line 45

def self.create_evaluation(reputation_name, value, source, target)
  ReputationSystem::Evaluation.create!(:reputation_name => reputation_name.to_s, :value => value,
                       :source_id => source.id, :source_type => source.class.name,
                       :target_id => target.id, :target_type => target.class.name)
end

.exists?(options = {}) ⇒ Boolean

Returns:

  • (Boolean)


55
56
57
58
59
60
# File 'lib/reputation_system/models/evaluation.rb', line 55

def exists?(options={})
  if options[:source_type] && options[:target_type] && options[:reputation_name]
    options[:source_type] = get_source_type_for_sti(options[:source_type], options[:target_type], options[:reputation_name])
  end
  original_exists? options
end

.find_by_reputation_name_and_source_and_target(reputation_name, source, target) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/reputation_system/models/evaluation.rb', line 34

def self.find_by_reputation_name_and_source_and_target(reputation_name, source, target)
  source_type = get_source_type_for_sti(source.class.name, target.class.name, reputation_name)
  ReputationSystem::Evaluation.where(
    :reputation_name => reputation_name.to_s,
    :source_id => source.id,
    :source_type => source_type,
    :target_id => target.id,
    :target_type => target.class.name
  ).first
end

.original_exists?Object



53
# File 'lib/reputation_system/models/evaluation.rb', line 53

alias :original_exists? :exists?