class Clickatell::Catcher::Rack::SharedArray

Public Class Methods

new() click to toggle source
# File lib/clickatell/catcher/rack/shared_array.rb, line 9
def initialize
  @store = YAML::Store.new(store_patch)
  @store.transaction do |store|
    store[:data] ||= []
  end
end

Public Instance Methods

<<(item) click to toggle source
# File lib/clickatell/catcher/rack/shared_array.rb, line 34
def <<(item)
  @store.transaction do |store|
    store[:data].unshift(item)
    store[:data].pop if store[:data].size > 25
  end
end
clear() click to toggle source
# File lib/clickatell/catcher/rack/shared_array.rb, line 28
def clear
  @store.transaction do |store|
    store[:data] = []
  end
end
each() { |item| ... } click to toggle source
# File lib/clickatell/catcher/rack/shared_array.rb, line 41
def each
  data = @store.transaction { @store[:data] }
  data.each do |item|
    yield(item)
  end
end
size() click to toggle source
# File lib/clickatell/catcher/rack/shared_array.rb, line 48
def size
  @store.transaction { @store[:data] }.size
end

Private Instance Methods

store_patch() click to toggle source
# File lib/clickatell/catcher/rack/shared_array.rb, line 18
def store_patch
  if File.directory?('tmp')
    'tmp/clickatell_catcher.yml'
  else
    'clickatell_catcher.yml'
  end
end