class EventsEmitter::Base
Public Class Methods
new(type)
click to toggle source
# File lib/events_emitter/base.rb, line 3 def initialize(type) @backend = constantize("EventsEmitter::#{type.to_s.capitalize}").new rescue NameError => e raise ArgumentError.new("Unsupported emitter: #{type}") end
Public Instance Methods
event(key, value = 1)
click to toggle source
# File lib/events_emitter/base.rb, line 9 def event(key, value = 1) @backend.record(key, value) end
Protected Instance Methods
constantize(camel_cased_word)
click to toggle source
Taken from ActiveSupport::Inflector
# File lib/events_emitter/base.rb, line 16 def constantize(camel_cased_word) names = camel_cased_word.split('::') names.shift if names.empty? || names.first.empty? constant = Object names.each do |name| constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name) end constant end