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

Instance Method Details

#acceptObject



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

#discardObject



27
28
29
# File 'lib/the_moderator/moderation_model.rb', line 27

def discard
  destroy
end

#include?(attribute) ⇒ Boolean

Returns:

  • (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_dataObject



37
38
39
# File 'lib/the_moderator/moderation_model.rb', line 37

def parsed_data
  data
end

#parsed_data_displayObject



41
42
43
# File 'lib/the_moderator/moderation_model.rb', line 41

def parsed_data_display
  data_display
end

#previewObject



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