Class: OmniAuth::Configuration
- Inherits:
-
Object
- Object
- OmniAuth::Configuration
- Includes:
- Singleton
- Defined in:
- lib/kth_omniauth.rb
Constant Summary collapse
- @@defaults =
{ :camelizations => {}, :path_prefix => '/auth', :on_failure => OmniAuth::FailureEndpoint, :form_css => Form::DEFAULT_CSS, :test_mode => false, :logger => default_logger, :allowed_request_methods => [:get, :post], :mock_auth => { :default => AuthHash.new( 'provider' => 'default', 'uid' => '1234', 'info' => { 'name' => 'Bob Example' } ) } }
Instance Attribute Summary collapse
-
#allowed_request_methods ⇒ Object
Returns the value of attribute allowed_request_methods.
-
#camelizations ⇒ Object
Returns the value of attribute camelizations.
-
#form_css ⇒ Object
Returns the value of attribute form_css.
-
#full_host ⇒ Object
Returns the value of attribute full_host.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#mock_auth ⇒ Object
Returns the value of attribute mock_auth.
- #on_failure(&block) ⇒ Object
-
#path_prefix ⇒ Object
Returns the value of attribute path_prefix.
-
#test_mode ⇒ Object
Returns the value of attribute test_mode.
Class Method Summary collapse
Instance Method Summary collapse
-
#add_camelization(name, camelized) ⇒ Object
This is a convenience method to be used by strategy authors so that they can add special cases to the camelization utility method that allows OmniAuth::Builder to work.
- #add_mock(provider, mock = {}) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
55 56 57 |
# File 'lib/kth_omniauth.rb', line 55 def initialize @@defaults.each_pair{|k,v| self.send("#{k}=",v)} end |
Instance Attribute Details
#allowed_request_methods ⇒ Object
Returns the value of attribute allowed_request_methods.
99 100 101 |
# File 'lib/kth_omniauth.rb', line 99 def allowed_request_methods @allowed_request_methods end |
#camelizations ⇒ Object
Returns the value of attribute camelizations.
99 100 101 |
# File 'lib/kth_omniauth.rb', line 99 def camelizations @camelizations end |
#form_css ⇒ Object
Returns the value of attribute form_css.
99 100 101 |
# File 'lib/kth_omniauth.rb', line 99 def form_css @form_css end |
#full_host ⇒ Object
Returns the value of attribute full_host.
99 100 101 |
# File 'lib/kth_omniauth.rb', line 99 def full_host @full_host end |
#logger ⇒ Object
Returns the value of attribute logger.
99 100 101 |
# File 'lib/kth_omniauth.rb', line 99 def logger @logger end |
#mock_auth ⇒ Object
Returns the value of attribute mock_auth.
99 100 101 |
# File 'lib/kth_omniauth.rb', line 99 def mock_auth @mock_auth end |
#on_failure(&block) ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/kth_omniauth.rb', line 59 def on_failure(&block) if block_given? @on_failure = block else @on_failure end end |
#path_prefix ⇒ Object
Returns the value of attribute path_prefix.
99 100 101 |
# File 'lib/kth_omniauth.rb', line 99 def path_prefix @path_prefix end |
#test_mode ⇒ Object
Returns the value of attribute test_mode.
99 100 101 |
# File 'lib/kth_omniauth.rb', line 99 def test_mode @test_mode end |
Class Method Details
.default_logger ⇒ Object
26 27 28 29 30 |
# File 'lib/kth_omniauth.rb', line 26 def self.default_logger logger = Logger.new(STDOUT) logger.progname = "omniauth" logger end |
.defaults ⇒ Object
51 52 53 |
# File 'lib/kth_omniauth.rb', line 51 def self.defaults @@defaults end |
Instance Method Details
#add_camelization(name, camelized) ⇒ Object
This is a convenience method to be used by strategy authors so that they can add special cases to the camelization utility method that allows OmniAuth::Builder to work.
94 95 96 |
# File 'lib/kth_omniauth.rb', line 94 def add_camelization(name, camelized) self.camelizations[name.to_s] = camelized.to_s end |
#add_mock(provider, mock = {}) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/kth_omniauth.rb', line 67 def add_mock(provider, mock={}) # Stringify keys recursively one level. mock.keys.each do |key| mock[key.to_s] = mock.delete(key) end mock.each_pair do |key, val| if val.is_a? Hash val.keys.each do |subkey| val[subkey.to_s] = val.delete(subkey) end end end # Merge with the default mock and ensure provider is correct. mock = self.mock_auth[:default].dup.merge(mock) mock["provider"] = provider.to_s # Add it to the mocks. self.mock_auth[provider.to_sym] = mock end |