Class: RulesIO::Base
- Inherits:
-
Object
- Object
- RulesIO::Base
- Defined in:
- lib/rulesio/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#buffer ⇒ Object
include Singleton.
-
#token ⇒ Object
include Singleton.
Instance Method Summary collapse
- #flush ⇒ Object
-
#initialize(token) ⇒ Base
constructor
A new instance of Base.
- #send_event(event) ⇒ Object
Constructor Details
Instance Attribute Details
#buffer ⇒ Object
include Singleton
4 5 6 |
# File 'lib/rulesio/base.rb', line 4 def buffer @buffer end |
#token ⇒ Object
include Singleton
4 5 6 |
# File 'lib/rulesio/base.rb', line 4 def token @token end |
Instance Method Details
#flush ⇒ Object
16 17 18 19 20 |
# File 'lib/rulesio/base.rb', line 16 def flush return if (events = @buffer).empty? @buffer = [] RulesIO.queue.push(:payload => events, :token => @token) end |
#send_event(event) ⇒ Object
12 13 14 |
# File 'lib/rulesio/base.rb', line 12 def send_event(event) @buffer << prepare_event(event) end |