Module: Validatable::Understandable

Included in:
ValidationBase
Defined in:
lib/validatable/understandable.rb

Overview

:nodoc:

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



18
19
20
# File 'lib/validatable/understandable.rb', line 18

def self.included(klass)
  klass.extend ClassMethods
end

Instance Method Details

#must_understand(hash) ⇒ Object

Raises:

  • (ArgumentError)


22
23
24
25
26
27
28
29
# File 'lib/validatable/understandable.rb', line 22

def must_understand(hash)
  invalid_options = hash.inject([]) do |errors, (key, value)|
    errors << key.to_s unless self.class.all_understandings.include?(key)
    errors
  end
  raise ArgumentError.new("invalid options: #{invalid_options.join(', ')}") if invalid_options.any?
  true
end