module Jackal::Utils::Config

Public Class Methods

extended(klass) click to toggle source

Load extra modules automatically

# File lib/jackal/utils/config.rb, line 15
def self.extended(klass)
  klass.class_eval do
    extend Bogo::AnimalStrings
  end
end
included(klass) click to toggle source

Load extra modules automatically

# File lib/jackal/utils/config.rb, line 8
def self.included(klass)
  klass.class_eval do
    include Bogo::AnimalStrings
  end
end

Public Instance Methods

app_config() click to toggle source

@return [Smash] application configuration

# 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() click to toggle source

@return [String] name of the host running the application

# File lib/jackal/utils/config.rb, line 49
def app_host
  app_config.fetch(:app_host, Socket.gethostname)
end
config() click to toggle source

@return [Smash] configuration

# File lib/jackal/utils/config.rb, line 59
def config
  service_config[:config] || Smash.new
end
config_path(class_name = self.class.name) click to toggle source

@return [Array] key path in configuration

# 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) click to toggle source

Generate destination key based on direction

@param direction [Symbol, String] @param payload [Smash] @return [Symbol]

# File lib/jackal/utils/config.rb, line 68
def destination(direction, payload)
  [source_prefix, direction].map(&:to_s).join('_').to_sym
end
service_config() click to toggle source

@return [Smash] service configuration

# 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) click to toggle source

@return [Symbol] name of service

# 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() click to toggle source

@return [String] prefix of source for this callback

# File lib/jackal/utils/config.rb, line 34
def source_prefix
  config_path.join('_')
end