Module: Frivol::Config

Defined in:
lib/frivol.rb

Overview

Frivol::Config

Sets the Frivol configuration (currently only the Redis config), allows access to the configured Redis instance, and has a helper method to include Frivol in a class with an optional storage expiry parameter

Class Method Summary collapse

Class Method Details

.include_in(host_class, storage_expires_in = nil) ⇒ Object

A convenience method to include Frivol in a class, with an optional storage expiry parameter.

For example, you might have the following in environment.rb:

Frivol::Config.redis_config = REDIS_CONFIG
Frivol::Config.include_in ActiveRecord::Base, 600

Which would include Frivol in ActiveRecord::Base and set the default storage expiry to 10 minutes



180
181
182
183
# File 'lib/frivol.rb', line 180

def self.include_in(host_class, storage_expires_in = nil)
  host_class.send(:include, Frivol)
  host_class.storage_expires_in storage_expires_in if storage_expires_in
end

.redisObject

Returns the configured Redis instance



170
171
172
# File 'lib/frivol.rb', line 170

def self.redis
  @@redis
end

.redis_config=(config) ⇒ Object

Set the Redis configuration.

Expects a hash such as

REDIS_CONFIG = {
  :host => "localhost", 
  :port => 6379
}
Frivol::Config.redis_config = REDIS_CONFIG


165
166
167
# File 'lib/frivol.rb', line 165

def self.redis_config=(config)
  @@redis = Redis.new(config)
end