Sha256: 7bcd72e6b7758316b657907d6f13b2065382f53f8216e16e46b6b26681cf44af

Contents?: true

Size: 800 Bytes

Versions: 20

Compression:

Stored size: 800 Bytes

Contents

# encoding: utf-8

module Nimbu
  module Request
    module Validations
      module Token

        TOKEN_REQUIRED = [
          'get /sites',
          'get /channels'
        ]

        TOKEN_REQUIRED_REGEXP = [
          /channels\/.*\/.*\/entries/,
        ]

        # Ensures that required authentication token is present before
        # request is sent.
        #
        def validates_token_for(method, path)
          return true unless TOKEN_REQUIRED.grep("#{method} #{path}").empty?

          token_required = false
          TOKEN_REQUIRED_REGEXP.each do |regex|
            if "#{method} #{path}" =~ regex
              token_required = true
            end
          end
          return token_required
        end

      end # Token
    end # Validations
  end # Request
end # Nimbu

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
nimbu-api-0.5.0 lib/nimbu-api/request/validations/token.rb
nimbu-api-0.4.4 lib/nimbu-api/request/validations/token.rb
nimbu-api-0.4.3 lib/nimbu-api/request/validations/token.rb
nimbu-api-0.4.2 lib/nimbu-api/request/validations/token.rb
nimbu-api-0.4.1 lib/nimbu-api/request/validations/token.rb
nimbu-api-0.4.0 lib/nimbu-api/request/validations/token.rb
nimbu-api-0.3.0 lib/nimbu-api/request/validations/token.rb
nimbu-api-0.2.1 lib/nimbu-api/request/validations/token.rb
nimbu-api-0.2 lib/nimbu-api/request/validations/token.rb
nimbu-api-0.2.beta.3 lib/nimbu-api/request/validations/token.rb
nimbu-api-0.2.beta.2 lib/nimbu-api/request/validations/token.rb
nimbu-api-0.2.beta.1 lib/nimbu-api/request/validations/token.rb
nimbu-api-0.2.beta lib/nimbu-api/request/validations/token.rb
nimbu-api-0.1.5 lib/nimbu-api/request/validations/token.rb
nimbu-api-0.1.4 lib/nimbu-api/request/validations/token.rb
nimbu-api-0.1.3 lib/nimbu-api/request/validations/token.rb
nimbu-api-0.1.1 lib/nimbu-api/request/validations/token.rb
nimbu-api-0.1 lib/nimbu-api/request/validations/token.rb
nimbu-api-0.0.2 lib/nimbu-api/request/validations/token.rb
nimbu-api-0.0.1 lib/nimbu-api/request/validations/token.rb