Module: Filterameter::Errors

Overview

# Errors

Module Errors provides valid? and errors to implementing classes. If the valid? method is not overridden, then it returns true.

To provide validations rules, override validate. If any fail, populate the errors attribute with the reason for the failures.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



12
13
14
# File 'lib/filterameter/errors.rb', line 12

def errors
  @errors
end

Instance Method Details

#valid?(model = nil) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
# File 'lib/filterameter/errors.rb', line 14

def valid?(model = nil)
  @errors = []
  validate(model)
  @errors.empty?
end