Sha256: be01a227492cff5b5280d7ea40673126a54aa0772b1aca4d0be75154c1f2023f

Contents?: true

Size: 438 Bytes

Versions: 3

Compression:

Stored size: 438 Bytes

Contents

module Yema
  module Validations

    def self.included(base)
      super
      base.extend(ClassMethods)
    end

    def valid?
      errors.empty?
    end

    def rules
      self.class.rules
    end

    def errors
      Set.new.tap do |errors|
        rules.each { |rule| errors.merge(rule.errors(self)) }
      end
    end

    module ClassMethods
      def rules
        @rules ||= Registry::Rule.new
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
yema-0.0.3 lib/yema/validations.rb
yema-0.0.2 lib/yema/validations.rb
yema-0.0.1 lib/yema/validations.rb