Sha256: e82677a09d539d195fc26180accf35021356cc8e6f7f804d5f907380e892c0e2
Contents?: true
Size: 902 Bytes
Versions: 3
Compression:
Stored size: 902 Bytes
Contents
# -*- encoding: utf-8 -*- require 'data_mapper/validation/rule' module DataMapper module Validation class Rule class Method < Rule EQUALIZE_ON = superclass::EQUALIZE_ON.dup << :method equalize *EQUALIZE_ON attr_reader :method def initialize(attribute_name, options={}) super @method = options.fetch(:method, attribute_name) @violation_type = options.fetch(:violation_type, :unsatisfied_condition) end def validate(resource) result, error_message = resource.__send__(method) if result nil else Violation.new(resource, error_message, self) end end def violation_type(resource) @violation_type end end # class Method end # class Rule end # module Validation end # module DataMapper
Version data entries
3 entries across 3 versions & 1 rubygems