:entity, validates :censor_status, inclusion: Censorable end module ClassMethods def censor_passed where(status: Censorable::PASSED_STATUSES) end end def censor_passed? censor_status.passed? end
# and question specific definitions.. end class Answer < AR::Base include Taggable include Commentable include Censorable # and question answer definitions.. end
.... else .... end end def request_monitoring! req = monitor_requests.create!(content: monitor res = post_monitor_request(req) unless res.code == '200' raise Censorable::MonitorRequestFailed.new(re end Bad case
req = create!(entity: entity, content: monito res = post_monitor_request(req) unless res.code == '200' raise Censorable::MonitorRequestFailed.new( end end end end Good case
content = entity.monitoring_content ... class Question < AR::Base def monitoring_content [title, body].join("\n\n") end end class Answer < AR::Base def monitoring_content; body; end end Template method