Module: HasModerated::ModeratedAttributes::InstanceMethods

Defined in:
lib/has_moderated/moderated_attributes.rb

Instance Method Summary collapse

Instance Method Details

#to_moderationObject



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/has_moderated/moderated_attributes.rb', line 66

def to_moderation
  moderations = []
  self.changes.each_pair do |att_name, values|
    att_name = att_name.to_s
    if self.class.moderated_attributes.include?(att_name) && !(values[0].blank? && values[1].blank?)
      moderations.push(create_moderation_with_hooks!(
        :attributes => {
          att_name => self.get_moderation_attributes[att_name]
        }
      ))
      self.send(att_name+"=", values[0])
    end
  end

  moderations
end