Module: BiolaLogs::Generators

Defined in:
lib/biola_logs/generators.rb,
lib/biola_logs/generators/base.rb,
lib/biola_logs/generators/params.rb,
lib/biola_logs/generators/headers.rb

Defined Under Namespace

Classes: Base, Headers, Params

Class Method Summary collapse

Class Method Details

.allObject



3
4
5
6
7
8
# File 'lib/biola_logs/generators.rb', line 3

def self.all
  # Class method to get all classes in the BiolaLogs::Generators module 
  # returns an Array, skipping BiolaLogs::Generators::Base
  # example: [BiolaLogs::Generators::Params, BiolaLogs::Generators::Headers] 
  self.constants.map(&self.method(:const_get)).grep(Class) - [Base]
end

.handlerObject



10
11
12
13
14
15
16
17
18
# File 'lib/biola_logs/generators.rb', line 10

def self.handler
  # Class method that returns a hash of key/value pairs for `config.lograge.custom_options`
  # Calls to_hash() on all generators and merges the results into a single hash
  Proc.new do |event|
    self.all.each_with_object({}) do |klass, hash|
      hash.merge! klass.new(event).to_hash
    end
  end
end