Module: Jackal::Utils::Config

Included in:
Carnivore::Http::PointBuilder::Endpoint, Callback, Callback
Defined in:
lib/jackal/utils/config.rb

Instance Method Summary (collapse)

Instance Method Details

- (Hash) config

Returns configuration

Returns:

  • (Hash)

    configuration



20
21
22
# File 'lib/jackal/utils/config.rb', line 20

def config
  Carnivore::Config.get(*config_path.push(:config)) || Smash.new
end

- (Array) config_path(class_name = self.class.name)

Returns key path in configuration

Returns:

  • (Array)

    key path in configuration



8
9
10
11
12
# File 'lib/jackal/utils/config.rb', line 8

def config_path(class_name = self.class.name)
  class_name.split('::')[0,2].map do |string|
    string.gsub(/(?<![A-Z])([A-Z])/, '_\1').sub(/^_/, '').downcase
  end
end

- (Symbol) destination(direction = :output)

Generation destination key based on direction

Parameters:

  • direction (Symbol, String) (defaults to: :output)

Returns:

  • (Symbol)


28
29
30
# File 'lib/jackal/utils/config.rb', line 28

def destination(direction = :output)
  [source_prefix, direction].map(&:to_s).join('_').to_sym
end

- (String) source_prefix

Returns prefix of source for this callback

Returns:

  • (String)

    prefix of source for this callback



15
16
17
# File 'lib/jackal/utils/config.rb', line 15

def source_prefix
  config_path.join('_')
end