Module: MerryGoRound

Defined in:
lib/merry_go_round.rb,
lib/merry_go_round/entry.rb,
lib/merry_go_round/query.rb,
lib/merry_go_round/utils.rb,
lib/merry_go_round/railtie.rb,
lib/merry_go_round/version.rb,
lib/merry_go_round/aggregator.rb,
lib/merry_go_round/aggregation.rb,
lib/rails/generators/merry_go_round/install/install_generator.rb

Defined Under Namespace

Modules: Generators, Utils Classes: Aggregation, Aggregator, Entry, Query, Railtie, Web

Constant Summary collapse

GRANULARITIES =
[:minute, :hour, :day, :week, :year].freeze
VERSION =
'0.0.6'

Class Method Summary collapse

Class Method Details

.aggregate!Object



11
12
13
# File 'lib/merry_go_round.rb', line 11

def self.aggregate!
  Aggregator.new.aggregate!
end

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (MerryGoRound)

    the object that the method was called on



7
8
9
# File 'lib/merry_go_round.rb', line 7

def self.configure
  yield self
end

.granularitiesObject



42
43
44
# File 'lib/merry_go_round.rb', line 42

def self.granularities
  GRANULARITIES
end

.record(*args) ⇒ Object



15
16
17
# File 'lib/merry_go_round.rb', line 15

def self.record(*args)
  Entry.new(*args).record!
end

.redisObject



19
20
21
22
23
24
25
# File 'lib/merry_go_round.rb', line 19

def self.redis
  # Set redis to nothing make the setter run and setup a default if it's nothing
  self.redis = {} unless defined? @@redis

  # Return the namespaced Redis instance
  @@redis
end

.redis=(options = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/merry_go_round.rb', line 27

def self.redis=(options = {})
  client = nil
  if options.is_a?(Redis)
    client = options
  else
    url = options[:url] || determine_redis_provider || 'redis://localhost:6379/0'
    driver = options[:driver] || 'ruby'
    namespace = options[:namespace] || 'merry_go_round'

    client = Redis.connect(url: url, driver: driver)
  end

  @@redis = Redis::Namespace.new(namespace, redis: client)
end