Module: Dbhero::Configuration

Included in:
Dbhero
Defined in:
lib/dbhero/configuration.rb

Constant Summary collapse

VALID_CONFIG_KEYS =
[:authenticate, :current_user_method, :custom_user_auth_condition,
:user_representation, :google_api_id, :google_api_secret].freeze
DEFAULT_AUTHENTICATE =
true
DEFAULT_CURRENT_USER_METHOD =
:current_user
DEFAULT_GOOGLE_API_ID =
''
DEFAULT_GOOGLE_API_SECRET =
''
DEFAULT_USER_PRESENTATION =
:email
DEFAULT_CUSTOM_USER_AUTH_CONDITION =
nil

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



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

def self.extended(base)
  base.reset
end

Instance Method Details

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

Yields:

  • (_self)

Yield Parameters:



19
20
21
# File 'lib/dbhero/configuration.rb', line 19

def configure
  yield self if block_given?
end

#optionsObject



23
24
25
# File 'lib/dbhero/configuration.rb', line 23

def options
  Hash[ * VALID_CONFIG_KEYS.map { |key| [key, send(key)] }.flatten ]
end

#resetObject



27
28
29
30
31
32
33
34
# File 'lib/dbhero/configuration.rb', line 27

def reset
  self.authenticate = DEFAULT_AUTHENTICATE
  self.current_user_method = DEFAULT_CURRENT_USER_METHOD
  self.user_representation = DEFAULT_USER_PRESENTATION
  self.google_api_id = DEFAULT_GOOGLE_API_ID
  self.google_api_secret = DEFAULT_GOOGLE_API_SECRET
  self.custom_user_auth_condition = DEFAULT_CUSTOM_USER_AUTH_CONDITION
end