Module: HasModerated::ModeratedAttributes::ApplyModeration

Defined in:
lib/has_moderated/moderated_attributes.rb

Class Method Summary collapse

Class Method Details

.apply(rec, value, preview_mode = false) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/has_moderated/moderated_attributes.rb', line 52

def self.apply(rec, value, preview_mode = false)
  if value[:attributes].present?
    rec.instance_variable_set(:@has_moderated_preview, true) if preview_mode
    Moderation.without_moderation do
      value[:attributes].each_pair do |attr_name, attr_value|
        rec.send(attr_name.to_s+"=", attr_value)
      end
    end
  end
  rec
end