Module: WellFormed::Performer

Included in:
SimpleAction
Defined in:
lib/well_formed/performer.rb

Defined Under Namespace

Modules: Abstract, ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



13
14
15
16
17
18
# File 'lib/well_formed/performer.rb', line 13

def self.included(base)
  base.include(ActiveSupport::Callbacks)
  base.define_callbacks(:perform)
  base.extend(ClassMethods)
  base.prepend(Abstract)
end

Instance Method Details

#submitObject



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/well_formed/performer.rb', line 39

def submit
  return false unless valid?

  performed = false
  run_callbacks(:perform) do
    perform
    performed = true
  end
  errors.add(:base, :could_not_be_performed, message: "could not be performed") if !performed && errors.empty?
  performed
end

#submit!Object



35
36
37
# File 'lib/well_formed/performer.rb', line 35

def submit!
  submit || raise(WellFormed::RecordInvalid.new(self))
end