Class: Nexaas::Async::Collector::Persist

Inherits:
Object
  • Object
show all
Defined in:
lib/nexaas/async/collector/persist.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Persist

Returns a new instance of Persist.



8
9
10
11
# File 'lib/nexaas/async/collector/persist.rb', line 8

def initialize(opts={})
  @opts = opts.with_indifferent_access
  @storage = Storage.new
end

Instance Attribute Details

#optsObject (readonly)

Returns the value of attribute opts.



6
7
8
# File 'lib/nexaas/async/collector/persist.rb', line 6

def opts
  @opts
end

#storageObject (readonly)

Returns the value of attribute storage.



6
7
8
# File 'lib/nexaas/async/collector/persist.rb', line 6

def storage
  @storage
end

Class Method Details

.save(opts = {}) ⇒ Object



13
14
15
# File 'lib/nexaas/async/collector/persist.rb', line 13

def self.save(opts={})
  new(opts).save
end

Instance Method Details

#saveObject



17
18
19
20
# File 'lib/nexaas/async/collector/persist.rb', line 17

def save
  content = content_in_json(opts)
  storage.set(opts[:collect_id], content, expiration)
end