Class: Syncro::App
- Inherits:
-
Object
- Object
- Syncro::App
- Defined in:
- lib/syncro/app.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
- #add_scribe(scribe, &block) ⇒ Object
- #call(message) ⇒ Object
-
#initialize(client) ⇒ App
constructor
A new instance of App.
- #sync ⇒ Object
Constructor Details
#initialize(client) ⇒ App
Returns a new instance of App.
5 6 7 |
# File 'lib/syncro/app.rb', line 5 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
3 4 5 |
# File 'lib/syncro/app.rb', line 3 def client @client end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
3 4 5 |
# File 'lib/syncro/app.rb', line 3 def @message end |
Instance Method Details
#add_scribe(scribe, &block) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/syncro/app.rb', line 37 def add_scribe(scribe, &block) invoke( :add_scribe, :scribe => scribe, &block ) end |
#call(message) ⇒ Object
9 10 11 12 13 |
# File 'lib/syncro/app.rb', line 9 def call() @message = method = "invoke_#{.type}" send(method) if respond_to?(method) end |
#sync ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/syncro/app.rb', line 15 def sync invoke(:sync, :from => client.last_scribe_id) do |resp| scribes = resp.map {|s| scribe = Scriber::Scribe.new(s) scribe.from_client = client.to_s scribe } allowed_scribes = scribes.select {|s| allowed_klasses.include?(s.klass) } allowed_scribes.each {|s| s.play } if scribes.any? client.update_attribute( :last_scribe_id, scribes.last.id ) end yield if block_given? end end |