Module: Jackal::Utils::Config
- Included in:
- Carnivore::Http::PointBuilder::Endpoint, Callback
- Defined in:
- lib/jackal/utils/config.rb
Class Method Summary collapse
-
.extended(klass) ⇒ Object
Load extra modules automatically.
-
.included(klass) ⇒ Object
Load extra modules automatically.
Instance Method Summary collapse
-
#app_config ⇒ Smash
Application configuration.
-
#app_host ⇒ String
Name of the host running the application.
-
#config ⇒ Smash
Configuration.
-
#config_path(class_name = self.class.name) ⇒ Array
Key path in configuration.
-
#destination(direction, payload) ⇒ Symbol
Generate destination key based on direction.
-
#service_config ⇒ Smash
Service configuration.
-
#service_name(class_name = self.class.name) ⇒ Symbol
Name of service.
-
#source_prefix ⇒ String
Prefix of source for this callback.
Class Method Details
.extended(klass) ⇒ Object
Load extra modules automatically
15 16 17 18 19 |
# File 'lib/jackal/utils/config.rb', line 15 def self.extended(klass) klass.class_eval do extend Bogo::AnimalStrings end end |
.included(klass) ⇒ Object
Load extra modules automatically
8 9 10 11 12 |
# File 'lib/jackal/utils/config.rb', line 8 def self.included(klass) klass.class_eval do include Bogo::AnimalStrings end end |
Instance Method Details
#app_config ⇒ Smash
Returns application configuration.
39 40 41 42 43 44 45 46 |
# File 'lib/jackal/utils/config.rb', line 39 def app_config Carnivore::Config.fetch( snake( self.class.name.split('::').first ), Smash.new ) end |
#app_host ⇒ String
Returns name of the host running the application.
49 50 51 |
# File 'lib/jackal/utils/config.rb', line 49 def app_host app_config.fetch(:app_host, Socket.gethostname) end |
#config ⇒ Smash
Returns configuration.
59 60 61 |
# File 'lib/jackal/utils/config.rb', line 59 def config service_config[:config] || Smash.new end |
#config_path(class_name = self.class.name) ⇒ Array
Returns key path in configuration.
27 28 29 30 31 |
# File 'lib/jackal/utils/config.rb', line 27 def config_path(class_name = self.class.name) class_name.split('::')[0,2].map do |string| snake(string) end end |
#destination(direction, payload) ⇒ Symbol
Generate destination key based on direction
68 69 70 |
# File 'lib/jackal/utils/config.rb', line 68 def destination(direction, payload) [source_prefix, direction].map(&:to_s).join('_').to_sym end |
#service_config ⇒ Smash
Returns service configuration.
54 55 56 |
# File 'lib/jackal/utils/config.rb', line 54 def service_config Carnivore::Config.get(*config_path) || Smash.new end |
#service_name(class_name = self.class.name) ⇒ Symbol
Returns name of service.
22 23 24 |
# File 'lib/jackal/utils/config.rb', line 22 def service_name(class_name = self.class.name) config_path(class_name).last.to_sym end |
#source_prefix ⇒ String
Returns prefix of source for this callback.
34 35 36 |
# File 'lib/jackal/utils/config.rb', line 34 def source_prefix config_path.join('_') end |