Class: Stormpath::Rails::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/stormpath/rails/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_defined_config_hash) ⇒ Configuration

Returns a new instance of Configuration.



10
11
12
# File 'lib/stormpath/rails/configuration.rb', line 10

def initialize(user_defined_config_hash)
  @user_defined_config_hash = user_defined_config_hash
end

Instance Attribute Details

#user_defined_config_hashObject (readonly)

Returns the value of attribute user_defined_config_hash.



8
9
10
# File 'lib/stormpath/rails/configuration.rb', line 8

def user_defined_config_hash
  @user_defined_config_hash
end

Instance Method Details

#applicationObject



14
15
16
# File 'lib/stormpath/rails/configuration.rb', line 14

def application
  config_object.stormpath.application
end

#config_objectObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/stormpath/rails/configuration.rb', line 22

def config_object
  @config_object ||= RecursiveOpenStruct.new(merged_config_hashes).tap do |config|
    dynamic_config = Config::DynamicConfiguration.new(config)

    config.stormpath.application.href = dynamic_config.app.href
    config.stormpath.web.forgot_password.enabled = dynamic_config.forgot_password_enabled?
    config.stormpath.web.change_password.enabled = dynamic_config.change_password_enabled?
    config.stormpath.web.facebook_app_id = dynamic_config.facebook_app_id
    config.stormpath.web.facebook_app_secret = dynamic_config.facebook_app_secret
    config.stormpath.web.github_app_id = dynamic_config.github_app_id
    config.stormpath.web.github_app_secret = dynamic_config.github_app_secret
    config.stormpath.web.google_app_id = dynamic_config.google_app_id
    config.stormpath.web.linkedin_app_id = dynamic_config.linkedin_app_id
    config.stormpath.web.has_social_providers = dynamic_config.has_social_providers?
    config.stormpath.web.verify_email.enabled = dynamic_config.verify_email_enabled?
    config.stormpath.web.client_api = { enabled: dynamic_config.client_api_enabled,
                                        domain_name: dynamic_config.client_api_domain }
  end
end

#default_config_hashObject



46
47
48
49
50
# File 'lib/stormpath/rails/configuration.rb', line 46

def default_config_hash
  Config::ReadFile.new(
    File.expand_path(DEFAULT_CONFIG_RELATIVE_FILE_PATH, __FILE__)
  ).hash
end

#merged_config_hashesObject



42
43
44
# File 'lib/stormpath/rails/configuration.rb', line 42

def merged_config_hashes
  default_config_hash.deep_merge(user_defined_config_hash)
end

#webObject



18
19
20
# File 'lib/stormpath/rails/configuration.rb', line 18

def web
  config_object.stormpath.web
end