Module: OptOut

Extended by:
Forwardable
Defined in:
lib/opt_out.rb,
lib/opt_out/version.rb,
lib/opt_out/adapters.rb,
lib/opt_out/adapters/redis_adapter.rb,
lib/opt_out/adapters/memory_adapter.rb,
lib/opt_out/adapters/abstract_adapter.rb,
lib/opt_out/adapters/active_record_adapter.rb

Defined Under Namespace

Modules: Adapters Classes: Configuration

Constant Summary collapse

VERSION =
'1.1.0'

Class Method Summary collapse

Class Method Details

.adapterObject

Private: returns a memoized instance of adapter to use


35
36
37
# File 'lib/opt_out.rb', line 35

def adapter
  @adapter ||= config.adapter.new(config.options)
end

.configObject

Public: Returns Configuration


54
55
56
# File 'lib/opt_out.rb', line 54

def config
  @config ||= Configuration.new
end

.configure(&blk) ⇒ Object

Public: Configure OptOut. Returns Configuration.

Example:

OptOut.configure do |c|
  c.adapter = OptOut::Adapters::RedisAdapter
  c.options = {:host => 'localhost', :port => '6379', :password => ''}
end

47
48
49
50
51
# File 'lib/opt_out.rb', line 47

def configure(&blk)
  blk.call(config)
  @adapter = nil  # invalidate adapter on reconfiguration
  config
end