Sha256: 1c0567a4e9ac2cffb65c60ea6dde592738d6c56328fee81a897926393716bf4a
Contents?: true
Size: 767 Bytes
Versions: 1
Compression:
Stored size: 767 Bytes
Contents
# -*- encoding: utf-8 -*- require 'aequitas/rule' module Aequitas class Rule class Method < Rule equalize_on *(superclass.equalizer.keys + [:method]) 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 Aequitas
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
aequitas-0.0.2 | lib/aequitas/rule/method.rb |