Module: Zeng::Indexer::ClassMethods

Defined in:
lib/zeng/indexer.rb

Instance Method Summary collapse

Instance Method Details

#connect(klass) ⇒ Object



47
48
49
# File 'lib/zeng/indexer.rb', line 47

def connect(klass)
  @backend = klass.backend
end

#create(key, values = []) ⇒ Object



55
56
57
58
59
# File 'lib/zeng/indexer.rb', line 55

def create(key, values=[])
  value = JSON.generate values
  @backend[key] = value
  new(key, value)
end

#find(key) ⇒ Object



51
52
53
# File 'lib/zeng/indexer.rb', line 51

def find(key)
  new(key, @backend[key]) if @backend[key]
end

#find_or_create(key) ⇒ Object



65
66
67
# File 'lib/zeng/indexer.rb', line 65

def find_or_create(key)
  find(key) || create(key)
end

#save(map) ⇒ Object



61
62
63
# File 'lib/zeng/indexer.rb', line 61

def save(map)
  @backend[map.key] = JSON.generate map.values
end