class Nexaas::Async::Collector::Persist

Attributes

opts[R]
storage[R]

Public Class Methods

new(opts={}) click to toggle source
# File lib/nexaas/async/collector/persist.rb, line 8
def initialize(opts={})
  @opts = opts.with_indifferent_access
  @storage = Storage.new
end
save(opts={}) click to toggle source
# File lib/nexaas/async/collector/persist.rb, line 13
def self.save(opts={})
  new(opts).save
end

Public Instance Methods

save() click to toggle source
# File lib/nexaas/async/collector/persist.rb, line 17
def save
  content = content_in_json(opts)
  storage.set(opts[:collect_id], content, expiration)
end

Private Instance Methods

content_in_json(opts) click to toggle source
# File lib/nexaas/async/collector/persist.rb, line 24
def content_in_json(opts)
  {
    'scope_id' => opts[:scope_id],
    'content' => (opts[:content] ? Base64.encode64(opts[:content].to_s) : nil),
    'file' => opts[:file]
  }.to_json
end
expiration() click to toggle source
# File lib/nexaas/async/collector/persist.rb, line 32
def expiration
  opts[:expiration] || Nexaas::Async::Collector.expiration
end