Sha256: fe755c5ddd93607de2bab5e8ac10178d7ad651596155d6daf8cb3f3024cdc69b
Contents?: true
Size: 821 Bytes
Versions: 14
Compression:
Stored size: 821 Bytes
Contents
module Mongoa module MongoMapper module Matchers class ValidateBase attr_reader :attribute def initialize(attribute) @attribute = attribute end def matches?(subject) @subject = subject @validation = find_validation end def validation_type raise "Redefine in the subclass" end private def model_class @subject.class end def find_validation attr_validations = model_class.validations.select { |validation| validation.attribute == attribute } return nil unless attr_validations validation = attr_validations.detect { |validation| validation.key.include?(validation_type) } end end end end end
Version data entries
14 entries across 14 versions & 1 rubygems