class Praxis::Stats::Plugin

Public Class Methods

new() click to toggle source
# File lib/praxis/stats.rb, line 23
def initialize
  @options = {config_file: 'config/stats.yml'}
end

Public Instance Methods

config_key() click to toggle source
# File lib/praxis/stats.rb, line 27
def config_key
  :stats # 'praxis.stats'
end
load_type(hash) click to toggle source
# File lib/praxis/stats.rb, line 49
def load_type(hash)
  type = hash[:type].constantize
  args = hash[:args]
  args_hash = case args
  when Attributor::Hash
    args.contents.symbolize_keys
  when Hash
    args.symbolize_keys
  when nil
    {}
  else
    raise "unknown args type: #{args.class.name}"
  end
  
  if args_hash.any?        
    type.new(**args_hash)
  else
    type.new
  end

end
prepare_config!(node) click to toggle source
# File lib/praxis/stats.rb, line 31
def prepare_config!(node)
  node.attributes do
    attribute :collector, Hash, default: {type: 'Harness::FakeCollector'} do
      key :type, String, required: true
      key :args, Hash
    end
    attribute :queue, Hash, default: {type: 'Harness::AsyncQueue' } do
      key :type, String, required: true
      key :args, Hash
    end
  end
end
setup!() click to toggle source
# File lib/praxis/stats.rb, line 44
def setup!
  Harness.config.collector = load_type(config.collector)
  Harness.config.queue = load_type(config.queue)
end