Class: Zaikio::OAuthClient::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/zaikio/oauth_client/configuration.rb

Constant Summary collapse

HOSTS =
{
  development: "http://hub.zaikio.test",
  test: "http://hub.zaikio.test",
  staging: "https://hub.staging.zaikio.com",
  sandbox: "https://hub.sandbox.zaikio.com",
  production: "https://hub.zaikio.com"
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



19
20
21
22
23
24
25
26
# File 'lib/zaikio/oauth_client/configuration.rb', line 19

def initialize
  @client_configurations = {}
  @around_auth_block = nil
  @sessions_controller_name = "sessions"
  @connections_controller_name = "connections"
  @subscriptions_controller_name = "subscriptions"
  Zaikio::AccessToken.logger = logger
end

Instance Attribute Details

#around_auth_blockObject (readonly)

Returns the value of attribute around_auth_block.



16
17
18
# File 'lib/zaikio/oauth_client/configuration.rb', line 16

def around_auth_block
  @around_auth_block
end

#client_configurationsObject (readonly)

Returns the value of attribute client_configurations.



16
17
18
# File 'lib/zaikio/oauth_client/configuration.rb', line 16

def client_configurations
  @client_configurations
end

#connections_controller_nameObject

Returns the value of attribute connections_controller_name.



16
17
18
# File 'lib/zaikio/oauth_client/configuration.rb', line 16

def connections_controller_name
  @connections_controller_name
end

#environmentObject

Returns the value of attribute environment.



16
17
18
# File 'lib/zaikio/oauth_client/configuration.rb', line 16

def environment
  @environment
end

#hostObject

Returns the value of attribute host.



15
16
17
# File 'lib/zaikio/oauth_client/configuration.rb', line 15

def host
  @host
end

#sessions_controller_nameObject

Returns the value of attribute sessions_controller_name.



16
17
18
# File 'lib/zaikio/oauth_client/configuration.rb', line 16

def sessions_controller_name
  @sessions_controller_name
end

#subscriptions_controller_nameObject

Returns the value of attribute subscriptions_controller_name.



16
17
18
# File 'lib/zaikio/oauth_client/configuration.rb', line 16

def subscriptions_controller_name
  @subscriptions_controller_name
end

Instance Method Details

#all_client_namesObject



46
47
48
# File 'lib/zaikio/oauth_client/configuration.rb', line 46

def all_client_names
  client_configurations.keys
end

#around_auth(&block) ⇒ Object



55
56
57
# File 'lib/zaikio/oauth_client/configuration.rb', line 55

def around_auth(&block)
  @around_auth_block = block
end

#find!(name) ⇒ Object



42
43
44
# File 'lib/zaikio/oauth_client/configuration.rb', line 42

def find!(name)
  @client_configurations[name.to_s] or raise ActiveRecord::RecordNotFound
end

#loggerObject



28
29
30
# File 'lib/zaikio/oauth_client/configuration.rb', line 28

def logger
  @logger ||= ActiveSupport::Logger.new($stdout)
end

#logger=(logger) ⇒ Object



32
33
34
35
# File 'lib/zaikio/oauth_client/configuration.rb', line 32

def logger=(logger)
  @logger = logger
  Zaikio::AccessToken.logger = @logger
end

#register_client(name) {|| ... } ⇒ Object

Yields:

  • ()


37
38
39
40
# File 'lib/zaikio/oauth_client/configuration.rb', line 37

def register_client(name)
  @client_configurations[name.to_s] ||= ClientConfiguration.new(name.to_s)
  yield(@client_configurations[name.to_s])
end