Module: Gotcha::ControllerHelpers

Defined in:
lib/gotcha/controller_helpers.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
# File 'lib/gotcha/controller_helpers.rb', line 5

def self.included(base)
  base.send(:helper_method, :gotcha_valid?)
end

Instance Method Details

#gotcha_valid?(expected = 1) ⇒ Boolean

return a true / false as to whether or not all of the gotchas on the page validated

Returns:

  • (Boolean)


10
11
12
13
# File 'lib/gotcha/controller_helpers.rb', line 10

def gotcha_valid?(expected = 1)
  return true if Gotcha.skip_validation?
  @_gotcha_validated ||= determine_gotcha_validity(expected)
end

#validate_gotcha!(expected = 1) ⇒ Object

Validate the gotcha, throw an exception if the gotcha does not validate (any on the page)

Raises:

  • (Gotcha::ValidationError)


16
17
18
# File 'lib/gotcha/controller_helpers.rb', line 16

def validate_gotcha!(expected = 1)
  raise Gotcha::ValidationError.new unless gotcha_valid?(expected)
end