Module: HasModerated::Common
- Defined in:
- lib/has_moderated/common.rb
Defined Under Namespace
Modules: InstanceMethods
Class Method Summary collapse
-
.call_creating_hook(model, moderation) ⇒ Object
calls user hooks for creation of a new moderation.
- .init(klass) ⇒ Object
- .try_without_moderation(rec) ⇒ Object
Class Method Details
.call_creating_hook(model, moderation) ⇒ Object
calls user hooks for creation of a new moderation
27 28 29 30 31 32 33 34 |
# File 'lib/has_moderated/common.rb', line 27 def self.call_creating_hook model, moderation if model.class.respond_to?(:moderation_hooks) model.class.moderation_hooks[:creating] ||= [] model.class.moderation_hooks[:creating].each do |hook| model.instance_exec moderation, &hook end end end |
.init(klass) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/has_moderated/common.rb', line 3 def self.init(klass) unless klass.instance_variable_defined? "@moderated_model" klass.instance_variable_set("@moderated_model", true) klass.class_eval do attr_writer :moderation_disabled def moderation_disabled @moderation_disabled || Moderation.moderation_disabled end end HasModerated::ActiveRecordHelpers::add_moderations_association klass end end |
.try_without_moderation(rec) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/has_moderated/common.rb', line 17 def self.try_without_moderation rec # TODO: fix this, this method should only be avail. to moderated models if rec.respond_to?(:moderation_disabled) rec.without_moderation(true) { |rec| yield(rec) } else yield(rec) end end |