Module: ReputationSystem::ReputationMethods
- Defined in:
- lib/reputation_system/reputation_methods.rb
Instance Method Summary collapse
- #activate_all_reputations ⇒ Object
- #deactivate_all_reputations ⇒ Object
- #normalized_reputation_for(reputation_name, *args) ⇒ Object
- #rank_for(reputation_name, *args) ⇒ Object
- #reputation_for(reputation_name, *args) ⇒ Object
- #reputations_activated?(reputation_name) ⇒ Boolean
Instance Method Details
#activate_all_reputations ⇒ Object
27 28 29 30 31 32 |
# File 'lib/reputation_system/reputation_methods.rb', line 27 def activate_all_reputations ReputationSystem::Reputation.find(:all, :conditions => {:target_id => self.id, :target_type => self.class.name, :active => false}).each do |r| r.active = true r.save! end end |
#deactivate_all_reputations ⇒ Object
34 35 36 37 38 39 |
# File 'lib/reputation_system/reputation_methods.rb', line 34 def deactivate_all_reputations ReputationSystem::Reputation.find(:all, :conditions => {:target_id => self.id, :target_type => self.class.name, :active => true}).each do |r| r.active = false r.save! end end |
#normalized_reputation_for(reputation_name, *args) ⇒ Object
23 24 25 |
# File 'lib/reputation_system/reputation_methods.rb', line 23 def normalized_reputation_for(reputation_name, *args) find_reputation(reputation_name, args.first).normalized_value end |
#rank_for(reputation_name, *args) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/reputation_system/reputation_methods.rb', line 46 def rank_for(reputation_name, *args) scope = args.first my_value = self.reputation_for(reputation_name, scope) self.class.count_with_reputation(reputation_name, scope, :all, :conditions => ["rs_reputations.value > ?", my_value] ) + 1 end |
#reputation_for(reputation_name, *args) ⇒ Object
19 20 21 |
# File 'lib/reputation_system/reputation_methods.rb', line 19 def reputation_for(reputation_name, *args) find_reputation(reputation_name, args.first).value end |
#reputations_activated?(reputation_name) ⇒ Boolean
41 42 43 44 |
# File 'lib/reputation_system/reputation_methods.rb', line 41 def reputations_activated?(reputation_name) r = ReputationSystem::Reputation.find(:first, :conditions => {:reputation_name => reputation_name.to_s, :target_id => self.id, :target_type => self.class.name}) r ? r.active : false end |