Module: HasModerated::Preview::Saveable

Defined in:
lib/has_moderated/moderation_preview.rb

Instance Method Summary collapse

Instance Method Details

#update_moderationObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/has_moderated/moderation_preview.rb', line 5

def update_moderation
  if @based_on_moderation.present?
    data = @based_on_moderation.parsed_data

    # attributes
    data[:attributes] ||= Hash.new
    @has_moderated_fake_attributes.each_pair do |key, value|
      if value != @attributes_initial[key]
        data[:attributes][key.to_s] = value
      end
    end

    @based_on_moderation.data = data
    @based_on_moderation.save
  end
end