Sha256: cebd75a36432e23401ad03e24e4dd2f2c96cf76a610d1096c45306d74d94d0d7

Contents?: true

Size: 572 Bytes

Versions: 51

Compression:

Stored size: 572 Bytes

Contents

module Doorkeeper
  module Validations
    extend ActiveSupport::Concern

    attr_accessor :error

    def validate
      @error = nil
      self.class.validations.each do |validation|
        break if @error
        @error = validation.last unless send("validate_#{validation.first}")
      end
    end

    def valid?
      validate
      @error.nil?
    end

    module ClassMethods
      def validate(attribute, options = {})
        validations << [attribute, options[:error]]
      end

      def validations
        @validations ||= []
      end
    end
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
doorkeeper-2.1.2 lib/doorkeeper/validations.rb
doorkeeper-2.1.1 lib/doorkeeper/validations.rb
doorkeeper-2.1.0 lib/doorkeeper/validations.rb
doorkeeper-2.0.1 lib/doorkeeper/validations.rb
doorkeeper-1.4.1 lib/doorkeeper/validations.rb
doorkeeper-2.0.0 lib/doorkeeper/validations.rb
doorkeeper-2.0.0.rc3 lib/doorkeeper/validations.rb
doorkeeper-2.0.0.rc2 lib/doorkeeper/validations.rb
doorkeeper-2.0.0.alpha1 lib/doorkeeper/validations.rb
doorkeeper-1.4.0 lib/doorkeeper/validations.rb
doorkeeper-1.3.1 lib/doorkeeper/validations.rb
doorkeeper-1.3.0 lib/doorkeeper/validations.rb
doorkeeper-1.2.0 lib/doorkeeper/validations.rb
doorkeeper-1.1.0 lib/doorkeeper/validations.rb
doorkeeper-1.0.0 lib/doorkeeper/validations.rb
doorkeeper-1.0.0.rc2 lib/doorkeeper/validations.rb
doorkeeper-1.0.0.rc1 lib/doorkeeper/validations.rb
doorkeeper-0.7.4 lib/doorkeeper/validations.rb
doorkeeper-0.7.3 lib/doorkeeper/validations.rb
doorkeeper-0.7.2 lib/doorkeeper/validations.rb