refactors conflictable behaviour

This commit is contained in:
rgarcia
2015-09-28 13:38:48 +02:00
parent 8e42055ece
commit 6d5d60c0df
3 changed files with 11 additions and 11 deletions

View File

@@ -0,0 +1,9 @@
module Conflictable
extend ActiveSupport::Concern
def conflictive?
return false unless flags_count > 0 && cached_votes_up > 0
cached_votes_up/flags_count.to_f < 5
end
end

View File

@@ -2,6 +2,7 @@ require 'numeric'
class Debate < ActiveRecord::Base
include Flaggable
include Taggable
include Conflictable
apply_simple_captcha
@@ -110,11 +111,6 @@ class Debate < ActiveRecord::Base
where(id: [debate_ids, tag_ids].flatten.compact)
end
def conflictive?
return false unless flags_count > 0 && cached_votes_up > 0
cached_votes_up/flags_count.to_f < 5
end
def after_hide
self.tags.each{ |t| t.decrement_custom_counter_for('Debate') }
end

View File

@@ -1,7 +1,7 @@
class Proposal < ActiveRecord::Base
include Flaggable
include Taggable
include Conflictable
apply_simple_captcha
acts_as_votable
@@ -42,11 +42,6 @@ class Proposal < ActiveRecord::Base
cached_votes_up
end
def conflictive?
return false unless flags_count > 0 && cached_votes_up > 0
cached_votes_up/flags_count.to_f < 5
end
def description
super.try :html_safe
end