Class: DataMapper::Validations::MethodValidator

### Home Classes Methods

### In Files

- lib/dm-validations/validators/method_validator.rb

### Parent

DataMapper::Validations::GenericValidator

### Methods

- ::new
- #==
- #call

### Files

- LICENSE
- README.rdoc

### Class/Module Index

Quicksearch

- DataMapper
- DataMapper::InvalidContextError
- DataMapper::Validate
- DataMapper::ValidationError
- DataMapper::Validations
- DataMapper::Validations::AbsenceValidator
- DataMapper::Validations::AcceptanceValidator
- DataMapper::Validations::AutoValidations
- DataMapper::Validations::AutoValidations::ModelExtension
- DataMapper::Validations::ClassMethods
- DataMapper::Validations::ConfirmationValidator
- DataMapper::Validations::Context
- DataMapper::Validations::ContextualValidators
- DataMapper::Validations::Format
- DataMapper::Validations::Format::Email
- DataMapper::Validations::Format::Url
- DataMapper::Validations::FormatValidator
- DataMapper::Validations::GenericValidator
- DataMapper::Validations::LengthValidator
- DataMapper::Validations::MethodValidator
- DataMapper::Validations::NumericalityValidator
- DataMapper::Validations::OrderedHash
- DataMapper::Validations::PresenceValidator
- DataMapper::Validations::PrimitiveTypeValidator
- DataMapper::Validations::UniquenessValidator
- DataMapper::Validations::UnknownValidationFormat
- DataMapper::Validations::ValidatesAbsence
- DataMapper::Validations::ValidatesAcceptance
- DataMapper::Validations::ValidatesConfirmation
- DataMapper::Validations::ValidatesFormat
- DataMapper::Validations::ValidatesLength
- DataMapper::Validations::ValidatesNumericality
- DataMapper::Validations::ValidatesPresence
- DataMapper::Validations::ValidatesPrimitiveType
- DataMapper::Validations::ValidatesUniqueness
- DataMapper::Validations::ValidatesWithBlock
- DataMapper::Validations::ValidatesWithMethod
- DataMapper::Validations::ValidatesWithin
- DataMapper::Validations::ValidationErrors
- DataMapper::Validations::WithinValidator
- Object

No matching classes.

# DataMapper::Validations::MethodValidator

@author Guy van den Berg @since 0.9

### Public Class Methods

new(field_name, options={}) click to toggle source

    # File lib/dm-validations/validators/method_validator.rb, line 7
    def initialize(field_name, options={})
      super
      @options[:method] = @field_name unless @options.key?(:method)
    end

### Public Instance Methods

==(other) click to toggle source

    # File lib/dm-validations/validators/method_validator.rb, line 18
    def ==(other)
      @options[:method] == other.instance_variable_get(:@options)[:method] && super
    end

call(target) click to toggle source

    # File lib/dm-validations/validators/method_validator.rb, line 12
    def call(target)
      result, message = target.__send__(@options[:method])
      add_error(target, message, field_name) unless result
      result
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.