class ImAlive::Log

Attributes

db_uri[R]
document_id[R]

Public Class Methods

new(db_uri, document_id) click to toggle source
# File lib/im_alive/log.rb, line 5
def initialize(db_uri, document_id)
  @db_uri = db_uri
  @document_id = document_id
end

Public Instance Methods

send() click to toggle source
# File lib/im_alive/log.rb, line 10
def send
  doc = begin
    db.get!(document_id)
  rescue CouchRest::NotFound
    {'_id' => document_id}
  end
  doc.merge!(timestamps)
  db.save_doc(doc)
end

Private Instance Methods

db() click to toggle source
# File lib/im_alive/log.rb, line 24
def db
  @db ||= CouchRest.database!(db_uri)
end
timestamps() click to toggle source
# File lib/im_alive/log.rb, line 28
def timestamps
  {
    "timestamp" => Time.now.utc.to_s,
    "js_timestamp" => Time.now.utc.to_i,
  }
end