Module: Totalizer
- Extended by:
- Totalizer
- Included in:
- Totalizer
- Defined in:
- lib/totalizer/base.rb,
lib/totalizer/step.rb,
lib/totalizer/errors.rb,
lib/totalizer/logger.rb,
lib/totalizer/metric.rb,
lib/totalizer/factory.rb,
lib/totalizer/message.rb,
lib/totalizer/railtie.rb,
lib/totalizer/version.rb,
lib/totalizer/notifier/log_notifier.rb,
lib/totalizer/notifier/base_notifier.rb,
lib/totalizer/notifier/email_notifier.rb,
lib/totalizer/notifier/slack_notifier.rb,
lib/totalizer/notifier/action_mailer_notifier.rb,
lib/totalizer/notifier/mandrill_mailer_notifier.rb
Defined Under Namespace
Modules: Errors
Classes: AcqusitionMessage, ActionMailerNotifier, ActivationMessage, ActivityMessage, BaseNotifier, ChurnMessage, EmailNotifier, EngagementMessage, Factory, LogNotifier, MandrillMailerNotifier, Message, Metric, MetricMessage, Railtie, RetentionMessage, SlackNotifier, Step, VanityMessage
Constant Summary
collapse
- NOTIFIERS =
{ log: 'Totalizer::LogNotifier', action_mailer: 'Totalizer::ActionMailerNotifier', mandrill_mailer: 'Totalizer::MandrillMailerNotifier', slack: 'Totalizer::SlackNotifier' }
- VERSION =
"0.1.7"
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#activity_metric ⇒ Object
Returns the value of attribute activity_metric.
4
5
6
|
# File 'lib/totalizer/base.rb', line 4
def activity_metric
@activity_metric
end
|
#growth_metric ⇒ Object
Returns the value of attribute growth_metric.
4
5
6
|
# File 'lib/totalizer/base.rb', line 4
def growth_metric
@growth_metric
end
|
#vanity_metric ⇒ Object
Returns the value of attribute vanity_metric.
4
5
6
|
# File 'lib/totalizer/base.rb', line 4
def vanity_metric
@vanity_metric
end
|
Class Method Details
.logger ⇒ Object
2
3
4
|
# File 'lib/totalizer/logger.rb', line 2
def self.logger
@@logger ||= defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
end
|
.logger=(logger) ⇒ Object
6
7
8
|
# File 'lib/totalizer/logger.rb', line 6
def self.logger=(logger)
@@logger = logger
end
|
Instance Method Details
#date=(date) ⇒ Object
37
38
39
|
# File 'lib/totalizer/base.rb', line 37
def date= date
factory.date = date
end
|
#descriptions ⇒ Object
6
7
8
9
10
11
12
13
14
|
# 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 ⇒ Object
33
34
35
|
# 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) ⇒ Object
58
59
60
61
|
# 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) ⇒ Object
41
42
43
44
|
# File 'lib/totalizer/base.rb', line 41
def generate build, duration=nil
factory.duration = duration
factory.send(build)
end
|
#notifiers ⇒ Object
46
47
48
|
# File 'lib/totalizer/base.rb', line 46
def notifiers
@notifiers ||= {}
end
|
#notifiers=(notifiers) ⇒ Object
50
51
52
|
# File 'lib/totalizer/base.rb', line 50
def notifiers= notifiers
@notifiers = notifiers
end
|
#notify(message_groups) ⇒ Object
54
55
56
|
# 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) ⇒ Object
#weekly_day ⇒ Object
63
64
65
|
# File 'lib/totalizer/base.rb', line 63
def weekly_day
@weekly_day ||= 1
end
|
#weekly_day=(day) ⇒ Object
67
68
69
|
# File 'lib/totalizer/base.rb', line 67
def weekly_day= day
@weekly_day = day
end
|