Class: Rack::OAuth2::Client::Grant

Inherits:
Object
  • Object
show all
Includes:
AttrOptional, AttrRequired
Defined in:
lib/rack/oauth2/client/grant.rb,
lib/rack/oauth2/client/grant/password.rb,
lib/rack/oauth2/client/grant/jwt_bearer.rb,
lib/rack/oauth2/client/grant/saml2_bearer.rb,
lib/rack/oauth2/client/grant/refresh_token.rb,
lib/rack/oauth2/client/grant/token_exchange.rb,
lib/rack/oauth2/client/grant/authorization_code.rb,
lib/rack/oauth2/client/grant/client_credentials.rb

Defined Under Namespace

Classes: AuthorizationCode, ClientCredentials, JWTBearer, Password, RefreshToken, SAML2Bearer, TokenExchange

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Grant

Returns a new instance of Grant.



7
8
9
10
11
12
# File 'lib/rack/oauth2/client/grant.rb', line 7

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

Instance Method Details

#as_json(options = {}) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/rack/oauth2/client/grant.rb', line 18

def as_json(options = {})
  (required_attributes + optional_attributes).inject({
    grant_type: grant_type
  }) do |hash, key|
    hash.merge! key => self.send(key)
  end
end

#grant_typeObject



14
15
16
# File 'lib/rack/oauth2/client/grant.rb', line 14

def grant_type
  self.class.name.demodulize.underscore.to_sym
end