Module: TheModerator::ModerationModel
- Extended by:
- ActiveSupport::Concern
- Included in:
- Moderation
- Defined in:
- lib/the_moderator/moderation_model.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #accept ⇒ Object
- #accept! ⇒ Object
- #discard ⇒ Object
- #include?(attribute) ⇒ Boolean
- #moderated_fields_for(assoc) ⇒ Object
- #parsed_data ⇒ Object
- #parsed_data_display ⇒ Object
- #preview ⇒ Object
Instance Method Details
#accept ⇒ Object
16 17 18 19 20 21 |
# File 'lib/the_moderator/moderation_model.rb', line 16 def accept self.class.transaction do destroy moderatable.update(data) end end |
#accept! ⇒ Object
23 24 25 |
# File 'lib/the_moderator/moderation_model.rb', line 23 def accept! accept || raise(TheModerator::ModerationNotAccepted) end |
#discard ⇒ Object
27 28 29 |
# File 'lib/the_moderator/moderation_model.rb', line 27 def discard destroy end |
#include?(attribute) ⇒ Boolean
45 46 47 |
# File 'lib/the_moderator/moderation_model.rb', line 45 def include?(attribute) include_attribute?(attribute, data[:attributes]) end |
#moderated_fields_for(assoc) ⇒ Object
49 50 51 |
# File 'lib/the_moderator/moderation_model.rb', line 49 def moderated_fields_for(assoc) (data[:attributes][assoc].try(:keys) || []) - [:id] end |
#parsed_data ⇒ Object
37 38 39 |
# File 'lib/the_moderator/moderation_model.rb', line 37 def parsed_data data end |
#parsed_data_display ⇒ Object
41 42 43 |
# File 'lib/the_moderator/moderation_model.rb', line 41 def parsed_data_display data_display end |
#preview ⇒ Object
31 32 33 34 35 |
# File 'lib/the_moderator/moderation_model.rb', line 31 def preview preview = moderatable.clone preview.attributes = data preview.freeze end |