Class: DataMapper::Validate::MethodValidator
- Inherits:
-
GenericValidator
- Object
- GenericValidator
- DataMapper::Validate::MethodValidator
- Defined in:
- lib/gems/dm-validations-0.9.9/lib/dm-validations/method_validator.rb
Overview
Instance Attribute Summary
Attributes inherited from GenericValidator
Instance Method Summary collapse
- #==(other) ⇒ Object
- #call(target) ⇒ Object
-
#initialize(field_name, options = {}) ⇒ MethodValidator
constructor
A new instance of MethodValidator.
Methods inherited from GenericValidator
#add_error, #execute?, #field_name
Constructor Details
#initialize(field_name, options = {}) ⇒ MethodValidator
Returns a new instance of MethodValidator.
10 11 12 13 14 |
# File 'lib/gems/dm-validations-0.9.9/lib/dm-validations/method_validator.rb', line 10 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
22 23 24 |
# File 'lib/gems/dm-validations-0.9.9/lib/dm-validations/method_validator.rb', line 22 def ==(other) @options[:method] == other.instance_variable_get(:@options)[:method] && super end |
#call(target) ⇒ Object
16 17 18 19 20 |
# File 'lib/gems/dm-validations-0.9.9/lib/dm-validations/method_validator.rb', line 16 def call(target) result, = target.send(@options[:method]) add_error(target,,@field_name) if !result result end |