Module: Frivol::Config

Defined in:
lib/frivol/config.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

.allow_json_createObject



19
20
21
# File 'lib/frivol/config.rb', line 19

def self.allow_json_create
  @@allow_json_create ||= []
end

.backendObject

Get the Backend.



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

def self.backend
  @@backend
end

.backend=(new_backend) ⇒ Object

Set the Backend.

Expects one of Frivol::Backend::Redis, Frivol::Backend::RedisDistributed, Frivol::Backend::Riak or Frivol::Backend::Multi



10
11
12
# File 'lib/frivol/config.rb', line 10

def self.backend=(new_backend)
  @@backend = new_backend
end

.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



29
30
31
32
# File 'lib/frivol/config.rb', line 29

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