Class: CloudFlow
- Inherits:
-
Object
- Object
- CloudFlow
- Defined in:
- lib/cloud_flow.rb
Instance Method Summary collapse
-
#initialize(name) ⇒ CloudFlow
constructor
A new instance of CloudFlow.
-
#on(name, &block) ⇒ Object
regist func correspond to given func name.
-
#start ⇒ Object
starts its work.
Constructor Details
#initialize(name) ⇒ CloudFlow
Returns a new instance of CloudFlow.
5 6 7 8 9 |
# File 'lib/cloud_flow.rb', line 5 def initialize(name) @namespace = name sqs = AWS::SQS.new @queue = sqs.queues.named("cloudflow_#{@namespace}") end |
Instance Method Details
#on(name, &block) ⇒ Object
regist func correspond to given func name. please avoid ‘on’, ‘poll’ since they are used already by CloudFlow. flow.on(:somefunc, &blk) generates flow#somefunc which is used to call the work.
16 17 18 19 |
# File 'lib/cloud_flow.rb', line 16 def on(name, &block) define_sending_method(name) define_receiving_method(name, &block) end |
#start ⇒ Object
starts its work.
22 23 24 25 26 |
# File 'lib/cloud_flow.rb', line 22 def start @queue.poll do |msg| (msg) end end |