Class: UseCaseValidations::CustomValidator

Inherits:
Validator
  • Object
show all
Defined in:
lib/usecasing_validations/custom_validator.rb

Instance Attribute Summary collapse

Attributes inherited from Validator

#base, #options

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ CustomValidator

Returns a new instance of CustomValidator.



7
8
9
10
11
# File 'lib/usecasing_validations/custom_validator.rb', line 7

def initialize(args)
  options = Helpers._extract_options!(args)
  @methods = args
  super(options)
end

Instance Attribute Details

#methodsObject (readonly)

Returns the value of attribute methods.



5
6
7
# File 'lib/usecasing_validations/custom_validator.rb', line 5

def methods
  @methods
end

Instance Method Details

#validate(record) ⇒ Object



13
14
15
16
17
# File 'lib/usecasing_validations/custom_validator.rb', line 13

def validate(record)
  [*methods].map do |method|
    base.send(method, record)
  end.all?
end