Class: WeakHeaders::BaseValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/weak_headers/base_validator.rb

Direct Known Subclasses

OptionalValidator, RequiresValidator

Instance Method Summary collapse

Constructor Details

#initialize(controller, key, options = {}, &block) ⇒ BaseValidator



3
4
5
6
7
8
# File 'lib/weak_headers/base_validator.rb', line 3

def initialize(controller, key, options = {}, &block)
  @controller = controller
  @key        = key.to_s
  @options    = options
  @block      = block
end

Instance Method Details

#typeObject



14
15
16
# File 'lib/weak_headers/base_validator.rb', line 14

def type
  self.class.name.split('::').last.sub(/Validator\z/, '').underscore.to_sym
end

#validateObject



10
11
12
# File 'lib/weak_headers/base_validator.rb', line 10

def validate
  handle_failure unless valid?
end