Class: ActionAlexa::Configuration
- Inherits:
-
Object
- Object
- ActionAlexa::Configuration
- Defined in:
- lib/action_alexa/configuration.rb
Overview
Configuration class to support application code hooks within the ActionAlexa gem. Configurations below that do not have hooks should be set within the Rails initializers (app/config/initializers/*.rb). This class should be used as a singleton instance through the ActionAlexa module
Constant Summary collapse
- MISSING_CURRENT_USER_HOOK_ERROR =
'No block set for #current_user_hook to execute'.freeze
- MISSING_DEFAULT_INTENT_ERROR =
'Default/Fallback Intent class not defined'.freeze
Instance Attribute Summary collapse
-
#current_user_hook(&block) ⇒ Object
Consumers can either pass a block into #current_user_hook or explicitly create a lambda/proc and assign it via the writer #current_user_hook=.
-
#default_intent_response_class ⇒ Object
rubocop:disable Style/IfUnlessModifier - rubocop is having issues with the code below but its fairly succicient, so disabling the check here.
- #logger ⇒ Object
- #root ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#current_user_hook(&block) ⇒ Object
Consumers can either pass a block into #current_user_hook or explicitly
create a lambda/proc and assign it via the writer #current_user_hook=
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/action_alexa/configuration.rb', line 17 def current_user_hook(&block) return @current_user_hook if current_user_hook? if block_given? @current_user_hook = block return end raise ActionAlexa::MissingConfiguration, MISSING_CURRENT_USER_HOOK_ERROR end |
#default_intent_response_class ⇒ Object
rubocop:disable Style/IfUnlessModifier - rubocop is having issues with
the code below but its fairly succicient, so disabling the check here
42 43 44 45 46 47 48 |
# File 'lib/action_alexa/configuration.rb', line 42 def default_intent_response_class if @default_intent_response_class.nil? raise ActionAlexa::MissingConfiguration, MISSING_DEFAULT_INTENT_ERROR end @default_intent_response_class end |
#logger ⇒ Object
36 37 38 |
# File 'lib/action_alexa/configuration.rb', line 36 def logger @logger ||= Rails.logger end |
#root ⇒ Object
32 33 34 |
# File 'lib/action_alexa/configuration.rb', line 32 def root @root ||= Rails.root end |
Instance Method Details
#current_user_hook? ⇒ Boolean
28 29 30 |
# File 'lib/action_alexa/configuration.rb', line 28 def current_user_hook? !@current_user_hook.nil? end |