Class: Qswarm::Connection
- Inherits:
-
Object
- Object
- Qswarm::Connection
- Defined in:
- lib/qswarm/connection.rb
Direct Known Subclasses
Qswarm::Connections::Amqp, Qswarm::Connections::Logger, Qswarm::Connections::Twitter, Qswarm::Connections::Xmpp
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
Returns the value of attribute format.
Instance Method Summary collapse
- #emit(payload) ⇒ Object
-
#initialize(agent, name, args, &block) ⇒ Connection
constructor
A new instance of Connection.
- #run ⇒ Object
- #sink(args, payload) ⇒ Object
Constructor Details
#initialize(agent, name, args, &block) ⇒ Connection
Returns a new instance of Connection.
5 6 7 8 9 10 11 12 |
# File 'lib/qswarm/connection.rb', line 5 def initialize(agent, name, args, &block) @agent = agent @name = name @args = args @on_connect = block_given? ? block : false @format = args[:format] || :raw end |
Instance Attribute Details
#format ⇒ Object (readonly)
Returns the value of attribute format.
3 4 5 |
# File 'lib/qswarm/connection.rb', line 3 def format @format end |
Instance Method Details
#emit(payload) ⇒ Object
14 15 16 |
# File 'lib/qswarm/connection.rb', line 14 def emit(payload) @agent.emit(@name, :payload => OpenStruct.new(:raw => payload, :format => @format)) end |
#run ⇒ Object
22 23 |
# File 'lib/qswarm/connection.rb', line 22 def run end |