Class: Atig::Agent::UserStream

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/atig/agent/user_stream.rb

Instance Method Summary collapse

Methods included from ExceptionUtil

daemon, safe

Constructor Details

#initialize(context, api, db) ⇒ UserStream

Returns a new instance of UserStream.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/atig/agent/user_stream.rb', line 9

def initialize(context, api, db)
  @log = context.log
  @api = api
  @prev = nil

  return unless context.opts.stream

  log :info, "initialize"

  @api.stream do|t|
    t.watch('user') do |status|
#            @log.debug status.inspect
      if status and status.user
        db.statuses.transaction do|d|
          d.add :status => status, :user => status.user, :source => :user_stream
        end
      end
    end
  end
end