module Sequel::Plugins::ThrowFailures::InstanceMethods

Public Instance Methods

valid?(opts = OPTS) click to toggle source

Catch any thrown HookFailed exceptions.

Calls superclass method
# File lib/sequel/plugins/throw_failures.rb, line 41
def valid?(opts = OPTS)
  catch_hook_failures{super} || false
end

Private Instance Methods

catch_hook_failures() { || ... } click to toggle source

Catch any HookFailed exceptions thrown inside the block, and return nil if there were any.

# File lib/sequel/plugins/throw_failures.rb, line 49
def catch_hook_failures
  called = ret = nil
  caught = catch(HookFailed) do
    ret = yield
    called = true
  end
  ret if called
end
checked_save_failure(opts) click to toggle source

Catch any thrown HookFailed exceptions if not raising on failure.

Calls superclass method
# File lib/sequel/plugins/throw_failures.rb, line 59
def checked_save_failure(opts)
  if raise_on_failure?(opts)
    super
  else
    catch_hook_failures{super}
  end
end
hook_failed_error(msg) click to toggle source

Throw HookFailed with the generated error. If the throw is not caught, just return the originally generated error.

Calls superclass method
# File lib/sequel/plugins/throw_failures.rb, line 70
def hook_failed_error(msg)
  e = super
  throw HookFailed, e
rescue UncaughtThrowError
  e
end
validation_failed_error() click to toggle source

Throw ValidationFailed with the generated error. If the throw is not caught, just return the originally generated error.

Calls superclass method
# File lib/sequel/plugins/throw_failures.rb, line 79
def validation_failed_error
  e = super
  throw ValidationFailed, e
rescue UncaughtThrowError
  e
end