Module: HasModerated::ModeratedCreate::InstanceMethods

Defined in:
lib/has_moderated/moderated_create.rb

Instance Method Summary collapse

Instance Method Details

#create_or_update_with_moderation(*args) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/has_moderated/moderated_create.rb', line 37

def create_or_update_with_moderation *args
  if valid? && new_record? && !self.moderation_disabled
    to_moderation_created
    true
  else
    create_or_update_without_moderation *args
  end
end

#to_moderation_createdObject



46
47
48
49
50
51
52
53
54
# File 'lib/has_moderated/moderated_create.rb', line 46

def to_moderation_created
  options = self.class.moderated_create_options
  assoc_attrs = HasModerated::ActiveRecordHelpers::get_assocs_for_moderation(options[:with_associations], self)

  create_moderation_with_hooks!(:create => {
    :attributes => get_moderation_attributes,
    :associations => assoc_attrs
  })
end