module Totalizer
Constants
- NOTIFIERS
- VERSION
Attributes
activity_metric[R]
growth_metric[R]
vanity_metric[R]
Public Class Methods
logger()
click to toggle source
# File lib/totalizer/logger.rb, line 2 def self.logger @@logger ||= defined?(Rails) ? Rails.logger : Logger.new(STDOUT) end
logger=(logger)
click to toggle source
# File lib/totalizer/logger.rb, line 6 def self.logger=(logger) @@logger = logger end
Public Instance Methods
activity_metric=(metric)
click to toggle source
# File lib/totalizer/base.rb, line 20 def activity_metric= metric @activity_metric = validate_metric(metric) end
date=(date)
click to toggle source
# File lib/totalizer/base.rb, line 37 def date= date factory.date = date end
descriptions()
click to toggle source
# File lib/totalizer/base.rb, line 6 def descriptions @descriptions ||= OpenStruct.new acquisition: "Signed up this period (with rate of change)", vanity: "Total this period (with rate of change)", activity: "Did key activity this period (with rate of change)", activation: "Created this period and did key activity", engagement: "Created before this period and did key activity this period", retention: "Did key activity the previous period and again this period", churn: "Did key activity last period but not this period over the total who did key activity last period plus new users" end
factory()
click to toggle source
# File lib/totalizer/base.rb, line 33 def factory @factory ||= Totalizer::Factory.new growth_metric, activity_metric, vanity_metric end
fire_notification(notifier_options, message_groups)
click to toggle source
# File lib/totalizer/base.rb, line 58 def fire_notification notifier_options, message_groups notifier = NOTIFIERS[notifier_options.first].constantize notifier.call(message_groups, notifier_options.last) end
generate(build, duration=nil)
click to toggle source
# File lib/totalizer/base.rb, line 41 def generate build, duration=nil factory.duration = duration factory.send(build) end
growth_metric=(metric)
click to toggle source
# File lib/totalizer/base.rb, line 16 def growth_metric= metric @growth_metric = validate_metric(metric) end
notifiers()
click to toggle source
# File lib/totalizer/base.rb, line 46 def notifiers @notifiers ||= {} end
notifiers=(notifiers)
click to toggle source
# File lib/totalizer/base.rb, line 50 def notifiers= notifiers @notifiers = notifiers end
notify(message_groups)
click to toggle source
# File lib/totalizer/base.rb, line 54 def notify message_groups notifiers.merge({ log: {} }).each { |notifier| fire_notification(notifier, message_groups) } end
validate_metric(metric)
click to toggle source
# File lib/totalizer/base.rb, line 28 def validate_metric metric raise Errors::InvalidMetric unless metric.kind_of?(Totalizer::Metric) metric end
vanity_metric=(metric)
click to toggle source
# File lib/totalizer/base.rb, line 24 def vanity_metric= metric @vanity_metric = validate_metric(metric) end
weekly_day()
click to toggle source
# File lib/totalizer/base.rb, line 63 def weekly_day @weekly_day ||= 1 end
weekly_day=(day)
click to toggle source
# File lib/totalizer/base.rb, line 67 def weekly_day= day @weekly_day = day end