Skip to content

Commit

Permalink
changed method names to be more descriptive, other minor
Browse files Browse the repository at this point in the history
fixes
  • Loading branch information
sent-hil committed Jan 9, 2013
1 parent 704f7a7 commit a709582
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
1 change: 0 additions & 1 deletion lib/open_auth2.rb
Expand Up @@ -13,7 +13,6 @@

require_relative 'open_auth2/delegate_to_config'
require_relative 'open_auth2/config'
#require_relative 'open_auth2/config'
require_relative 'open_auth2/connection'
require_relative 'open_auth2/token'
require_relative 'open_auth2/client'
Expand Down
4 changes: 2 additions & 2 deletions lib/open_auth2/config.rb
Expand Up @@ -46,7 +46,7 @@ def provider=(name)

# Removes all overwritten config & reset to default.
def reset_provider
remove_instance_vars
remove_stored_info
set_default_as_provider
end

Expand Down Expand Up @@ -89,7 +89,7 @@ def copy_provider_keys
end
end

def remove_instance_vars
def remove_stored_info
instance_variables.each do |var|
remove_instance_variable var
end
Expand Down
8 changes: 4 additions & 4 deletions lib/open_auth2/connection.rb
Expand Up @@ -11,7 +11,7 @@ def self.included(base)
end
end

# Yields: Faraday object, so user can choose choose their own
# Yields: Faraday object, so user can choose their own
# middleware.
#
# Examples:
Expand All @@ -24,14 +24,14 @@ def self.included(base)
#
# Returns: Faraday object.
#
def connection(&blk)
@connection ||= Faraday.new(:url => @faraday_url) do |builder|
def faraday_connection(&blk)
@faraday_connection ||= Faraday.new(:url => @faraday_url) do |builder|
builder.request :url_encoded
builder.adapter :net_http
builder.instance_eval(&blk) if block_given?
end

@connection
@faraday_connection
end
end
end
17 changes: 10 additions & 7 deletions lib/open_auth2/token.rb
Expand Up @@ -4,6 +4,9 @@ module OpenAuth2

# Gets Access/Refresh tokens from OAuth server.
class Token < Client

attr_reader :config

def initialize(config)
@config = config
@faraday_url = authorize_url
Expand Down Expand Up @@ -39,7 +42,7 @@ def build_code_url(params={})
# request.
#
def get(params={})
body = get_body_hash(params)
body = get_body(params)
raw_request = post(body)

parse(raw_request)
Expand All @@ -52,7 +55,7 @@ def get(params={})
# request.
#
def refresh(params={})
body = refresh_body_hash(params)
body = refresh_body(params)
raw_request = post(body)

parse(raw_request)
Expand All @@ -72,11 +75,11 @@ def host
end

def encoded_body(params)
URI.encode_www_form(url_body_hash(params))
URI.encode_www_form(url_body(params))
end

# Combine default options & user arguments.
def url_body_hash(params)
def url_body(params)

# user can define scope as String or Array
joined_scope = scope.join(',') if scope.respond_to?(:join)
Expand All @@ -89,7 +92,7 @@ def url_body_hash(params)
}.merge(params)
end

def get_body_hash(params)
def get_body(params)
{
:client_id => client_id,
:client_secret => client_secret,
Expand All @@ -99,7 +102,7 @@ def get_body_hash(params)
}.merge(params)
end

def refresh_body_hash(params)
def refresh_body(params)
{
:client_id => client_id,
:client_secret => client_secret,
Expand All @@ -119,7 +122,7 @@ def post(body)
end

def parse(response)
@config.parse(response.body)
config.parse(response.body)
response
end
end
Expand Down

0 comments on commit a709582

Please sign in to comment.