Class: OpenAuth2::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/open_auth2/config.rb

Overview

Holds the info required to make a valid request to an OAuth server.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Config

Use to set config info.

Examples:

OpenAuth2::Config.new do |c|
  c.provider = :default
end

Yields:

  • (_self)

Yield Parameters:



15
16
17
18
# File 'lib/open_auth2/config.rb', line 15

def initialize
  set_default_as_provider
  yield self if block_given?
end

Instance Attribute Details

#providerObject

Returns the value of attribute provider.



6
7
8
# File 'lib/open_auth2/config.rb', line 6

def provider
  @provider
end

#provider_constObject (readonly)

Returns the value of attribute provider_const.



6
7
8
# File 'lib/open_auth2/config.rb', line 6

def provider_const
  @provider_const
end

#provider_stringObject (readonly)

Returns the value of attribute provider_string.



6
7
8
# File 'lib/open_auth2/config.rb', line 6

def provider_string
  @provider_string
end

Instance Method Details

#configure {|_self| ... } ⇒ Object

Use to set config info.

Examples:

config = OpenAuth2::Config.new

config.configure do |c|
  c.provider = :google
end

Returns: self.

Yields:

  • (_self)

Yield Parameters:



31
32
33
# File 'lib/open_auth2/config.rb', line 31

def configure
  yield self if block_given?
end

#parse(response_body) ⇒ Object



53
54
55
# File 'lib/open_auth2/config.rb', line 53

def parse(response_body)
  @provider_const.new.parse(self, response_body)
end

#reset_providerObject

Removes all overwritten config & reset to default.



48
49
50
51
# File 'lib/open_auth2/config.rb', line 48

def reset_provider
  remove_instance_vars
  set_default_as_provider
end