Class: Syncro::Scriber::Scribe

Inherits:
SuperModel::Base
  • Object
show all
Includes:
SuperModel::Marshal::Model, SuperModel::RandomID, SuperModel::Redis::Model
Defined in:
lib/syncro/marshal.rb,
lib/syncro/redis/scribe.rb,
lib/syncro/scriber/scribe.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for_client(client) ⇒ Object



17
18
19
# File 'lib/syncro/redis/scribe.rb', line 17

def for_client(client)
  since(client, 0)
end

.since(client, id) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/syncro/redis/scribe.rb', line 7

def since(client, id)
  items  = redis.zrange(redis_key(:clients, client), id, -1)
  items += redis.zrange(redis_key(:clients, :all),   id, -1)
  items  = from_ids(items)
  items  = items.reject {|item|
    item.from_client == client.to_s
  }
  items
end

Instance Method Details

#klass=(klass) ⇒ Object



41
42
43
# File 'lib/syncro/scriber/scribe.rb', line 41

def klass=(klass)
  write_attribute(:klass, klass.to_s)
end

#playObject



37
38
39
# File 'lib/syncro/scriber/scribe.rb', line 37

def play
  klass.constantize.scribe_play(self)
end

#to_json(options = {}) ⇒ Object



45
46
47
48
49
50
# File 'lib/syncro/scriber/scribe.rb', line 45

def to_json(options = {})
  options[:except] ||= []
  options[:except] << :clients
  options[:except] << :from_client
  super(options)
end