module Ablab::ModuleMethods
Constants
- ALLOW_TRACKING
- TRACKING_EXCEPTION_HANDLER
Public Instance Methods
allow_tracking(&block)
click to toggle source
# File lib/ablab.rb, line 52 def allow_tracking(&block) @allow_tracking = block if block_given? @allow_tracking || ALLOW_TRACKING end
callbacks()
click to toggle source
# File lib/ablab.rb, line 65 def callbacks @callbacks || [] end
dashboard_credentials(credentials = nil)
click to toggle source
# File lib/ablab.rb, line 38 def dashboard_credentials(credentials = nil) if credentials unless credentials[:name] && credentials[:password] raise InvalidCredentials, 'credentials should provide name and password' end @dashboard_credentials = credentials end @dashboard_credentials end
experiment(name, &block)
click to toggle source
# File lib/ablab.rb, line 20 def experiment(name, &block) @experiments ||= {} @experiments[name] = Experiment.new(name, &block) end
experiments()
click to toggle source
# File lib/ablab.rb, line 12 def experiments @experiments ||= {} end
on_track(&block)
click to toggle source
# File lib/ablab.rb, line 48 def on_track(&block) (@callbacks ||= []) << block end
on_tracking_exception(&block)
click to toggle source
# File lib/ablab.rb, line 57 def on_tracking_exception(&block) @tracking_exception_handler = block end
setup(&block)
click to toggle source
# File lib/ablab.rb, line 16 def setup(&block) instance_exec(&block) end
store(type, *args)
click to toggle source
# File lib/ablab.rb, line 25 def store(type, *args) if type.is_a? Class @tracker = Class.new(*args) else class_name = type.to_s.split('_').map(&:capitalize).join @tracker = Ablab::Store.const_get(class_name).new(*args) end end
tracker()
click to toggle source
# File lib/ablab.rb, line 34 def tracker @tracker ||= Ablab::Store::Memory.new end
tracking_exception_handler()
click to toggle source
# File lib/ablab.rb, line 61 def tracking_exception_handler @tracking_exception_handler || TRACKING_EXCEPTION_HANDLER end