Sha256: d7e0aeaf07a3634b71450204876086fcda4fc79f5e72cfade69b880055851f4c

Contents?: true

Size: 864 Bytes

Versions: 1

Compression:

Stored size: 864 Bytes

Contents

module Rack
  module OAuth2
    class Client
      class Grant
        include AttrRequired, AttrOptional

        def initialize(attributes = {})
          (required_attributes + optional_attributes).each do |key|
            self.send "#{key}=", attributes[key]
          end
          attr_missing!
        end

        def to_hash
          (required_attributes + optional_attributes).inject({
            :grant_type => self.class.name.demodulize.underscore.to_sym
          }) do |hash, key|
            hash.merge! key => self.send(key)
          end.delete_if do |key, value|
            value.blank?
          end
        end
      end
    end
  end
end

require 'rack/oauth2/client/grant/authorization_code'
require 'rack/oauth2/client/grant/password'
require 'rack/oauth2/client/grant/client_credentials'
require 'rack/oauth2/client/grant/refresh_token'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rack-oauth2-0.8.6 lib/rack/oauth2/client/grant.rb