Class: WeakParameters::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/weak_parameters/validator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params, &block) ⇒ Validator

Returns a new instance of Validator.



5
6
7
8
# File 'lib/weak_parameters/validator.rb', line 5

def initialize(params, &block)
  @params = params
  instance_eval(&block)
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



3
4
5
# File 'lib/weak_parameters/validator.rb', line 3

def block
  @block
end

#paramsObject (readonly)

Returns the value of attribute params.



3
4
5
# File 'lib/weak_parameters/validator.rb', line 3

def params
  @params
end

Instance Method Details

#validateObject



10
11
12
# File 'lib/weak_parameters/validator.rb', line 10

def validate
  validators.each(&:validate)
end

#validatorsObject



14
15
16
# File 'lib/weak_parameters/validator.rb', line 14

def validators
  @validators ||= []
end