Module: RedisAnalytics::Helpers

Defined in:
lib/redis_analytics/helpers.rb

Constant Summary collapse

FORMAT_SPECIFIER =
[['%Y', 365], ['%m', 30], ['%d', 24], ['%H', 60], ['%M', 60]]
GRANULARITY =
['yearly', 'monthly', 'dayly', 'hourly', 'minutely']

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object (private)



9
10
11
12
13
14
15
16
17
# File 'lib/redis_analytics/helpers.rb', line 9

def method_missing(meth, *args, &block)
  if meth.to_s =~ /^(minute|hour|dai|day|month|year)ly_([a-z_0-9]+)$/
    granularity = ($1 == 'dai' ? 'day' : $1) + 'ly'
    metric_name = $2
    data(granularity, metric_name, *args)
  else
    super
  end
end