Sha256: c5f4e318f63892baf22168ed74571ef62f1aa6ab00e6e43524f680a2727130f4

Contents?: true

Size: 557 Bytes

Versions: 13

Compression:

Stored size: 557 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?
      @error.nil?
    end

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

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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
doorkeeper-0.5.0 lib/doorkeeper/validations.rb
doorkeeper-0.5.0.rc1 lib/doorkeeper/validations.rb
doorkeeper-0.4.2 lib/doorkeeper/validations.rb
doorkeeper-0.4.1 lib/doorkeeper/validations.rb
doorkeeper-0.4.0 lib/doorkeeper/validations.rb
doorkeeper-0.3.4 lib/doorkeeper/validations.rb
doorkeeper-0.3.3 lib/doorkeeper/validations.rb
doorkeeper-0.3.2 lib/doorkeeper/validations.rb
doorkeeper-0.3.1 lib/doorkeeper/validations.rb
doorkeeper-0.3.0 lib/doorkeeper/validations.rb
doorkeeper-0.2.0 lib/doorkeeper/validations.rb
doorkeeper-0.1.1 lib/doorkeeper/validations.rb
doorkeeper-0.1.0 lib/doorkeeper/validations.rb