Module: GLCommand::Validatable

Extended by:
ActiveSupport::Concern
Includes:
ActiveModel::Validations
Included in:
Callable
Defined in:
lib/gl_command/validatable.rb

Instance Method Summary collapse

Instance Method Details

#validatable_valid?Boolean

This is called in Callable.perform_call (via validate_validatable!)

Returns:

  • (Boolean)


21
22
23
24
25
# File 'lib/gl_command/validatable.rb', line 21

def validatable_valid?
  context.assign_callable(self) # used by validatable
  validate
  errors.none?
end

#validate_validatable!Object



27
28
29
30
31
# File 'lib/gl_command/validatable.rb', line 27

def validate_validatable!
  return true if validatable_valid?

  stop_and_fail!(ActiveRecord::RecordInvalid.new(self), no_notify: true)
end