module Actionable::MemoryStore

Public Class Methods

find(key) click to toggle source
# File lib/actionable/memory_store.rb, line 11
def self.find(key)
  model = hash[key]
end
find_by_target_id(target_id) click to toggle source
# File lib/actionable/memory_store.rb, line 15
def self.find_by_target_id(target_id)
  hash["target_#{target_id}"]
end
insert(model) click to toggle source
# File lib/actionable/memory_store.rb, line 4
def self.insert(model)
  key = (model[:id] ||= BSON::ObjectId.new.to_s)
  set(key,model)
  add(hash["target_#{model[:target_id]}"],model) if model[:target_id].present?
  model
end

Private Class Methods

add(key,model) click to toggle source
# File lib/actionable/memory_store.rb, line 41
def self.add(key,model)
  list = (hash[key] ||= [])
  list << model
  set(key,list)
end
clear() click to toggle source
# File lib/actionable/memory_store.rb, line 33
def self.clear
  @hash = {}
end
count() click to toggle source
# File lib/actionable/memory_store.rb, line 37
def self.count
  hash.length
end
get(key) click to toggle source
# File lib/actionable/memory_store.rb, line 29
def self.get(key)
  hash[key]
end
hash() click to toggle source
# File lib/actionable/memory_store.rb, line 21
def self.hash
  @hash ||= {}
end
set(key,value) click to toggle source
# File lib/actionable/memory_store.rb, line 25
def self.set(key,value)
  hash[key] = value
end