module MerryGoRound

Constants

GRANULARITIES
VERSION

Public Class Methods

aggregate!() click to toggle source
# File lib/merry_go_round.rb, line 11
def self.aggregate!
  Aggregator.new.aggregate!
end
configure() { |self| ... } click to toggle source
# File lib/merry_go_round.rb, line 7
def self.configure
  yield self
end
granularities() click to toggle source
# File lib/merry_go_round.rb, line 42
def self.granularities
  GRANULARITIES
end
record(*args) click to toggle source
# File lib/merry_go_round.rb, line 15
def self.record(*args)
  Entry.new(*args).record!
end
redis() click to toggle source
# 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 = {}) click to toggle source
# 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

Private Class Methods

determine_redis_provider() click to toggle source
# File lib/merry_go_round.rb, line 48
def self.determine_redis_provider
  return ENV['REDISTOGO_URL'] if ENV['REDISTOGO_URL']
  provider = ENV['REDIS_PROVIDER'] || 'REDIS_URL'
  ENV[provider]
end