class Momm::Bridge

Attributes

feed[R]
storage[R]

Public Class Methods

new(options={}) click to toggle source
# File lib/momm/bridge.rb, line 3
def initialize(options={})
  @storage = options[:store] || Memcached.new
  @feed = options[:feed] || Feeds::ECB.instance
end

Public Instance Methods

source(feed_name) click to toggle source

Inject the feed

Parameters

feed_name

currently only support ECB

Returns

the picked feed

Examples

source :ECB (which is by default)

# File lib/momm/bridge.rb, line 41
def source(feed_name)
  @feed = instance_eval("Momm::Feeds::#{feed_name}").instance
end
store(storage_name, kv={}) click to toggle source

Inject the storage

Parameters

storage_name

:redis_store or memcached. Memcached is set as default.

Returns

the picked storage

Examples

store :redis_store, port: 12345

# File lib/momm/bridge.rb, line 20
def store(storage_name, kv={})
  @storage = begin
    name = storage_name.to_s.split('_').map(&:capitalize).join
    klass = instance_eval "Momm::#{name}"

    klass.new kv
  end
end