Class: Momm::Bridge
- Inherits:
-
Object
- Object
- Momm::Bridge
- Defined in:
- lib/momm/bridge.rb
Instance Attribute Summary collapse
-
#feed ⇒ Object
readonly
Returns the value of attribute feed.
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Bridge
constructor
A new instance of Bridge.
-
#source(feed_name) ⇒ Object
Inject the feed.
-
#store(storage_name, kv = {}) ⇒ Object
Inject the storage.
Constructor Details
#initialize(options = {}) ⇒ Bridge
3 4 5 6 |
# File 'lib/momm/bridge.rb', line 3 def initialize(={}) @storage = [:store] || Memcached.new @feed = [:feed] || Feeds::ECB.instance end |
Instance Attribute Details
#feed ⇒ Object (readonly)
Returns the value of attribute feed.
45 46 47 |
# File 'lib/momm/bridge.rb', line 45 def feed @feed end |
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
45 46 47 |
# File 'lib/momm/bridge.rb', line 45 def storage @storage end |
Instance Method Details
#source(feed_name) ⇒ Object
Inject the feed
Parameters
- feed_name
-
currently only support ECB
Returns
the picked feed
Examples
source :ECB (which is by default)
41 42 43 |
# File 'lib/momm/bridge.rb', line 41 def source(feed_name) @feed = instance_eval("Momm::Feeds::#{feed_name}").instance end |
#store(storage_name, kv = {}) ⇒ Object
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
20 21 22 23 24 25 26 27 |
# 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 |