Class: CouchRest::Validation::MethodValidator
- Inherits:
-
GenericValidator
- Object
- GenericValidator
- CouchRest::Validation::MethodValidator
- Defined in:
- lib/couchrest/validation/validators/method_validator.rb
Overview
Instance Attribute Summary
Attributes inherited from GenericValidator
#field_name, #if_clause, #unless_clause
Instance Method Summary collapse
- #==(other) ⇒ Object
- #call(target) ⇒ Object
-
#initialize(field_name, options = {}) ⇒ MethodValidator
constructor
A new instance of MethodValidator.
Methods inherited from GenericValidator
Constructor Details
#initialize(field_name, options = {}) ⇒ MethodValidator
Returns a new instance of MethodValidator.
33 34 35 36 37 |
# File 'lib/couchrest/validation/validators/method_validator.rb', line 33 def initialize(field_name, ={}) super @field_name, @options = field_name, .clone @options[:method] = @field_name unless @options.has_key?(:method) end |
Instance Method Details
#==(other) ⇒ Object
45 46 47 |
# File 'lib/couchrest/validation/validators/method_validator.rb', line 45 def ==(other) @options[:method] == other.instance_variable_get(:@options)[:method] && super end |
#call(target) ⇒ Object
39 40 41 42 43 |
# File 'lib/couchrest/validation/validators/method_validator.rb', line 39 def call(target) result, = target.send(@options[:method]) add_error(target, , field_name) unless result result end |