Class: ActiveRedis::DirtyObjects::SortedSet

Inherits:
Array
  • Object
show all
Defined in:
lib/active_redis/dirty_objects/sorted_set.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Array

#clean!, #dirty?, #initialize

Constructor Details

This class inherits a constructor from ActiveRedis::DirtyObjects::Array

Instance Attribute Details

#hashObject

Returns the value of attribute hash.



4
5
6
# File 'lib/active_redis/dirty_objects/sorted_set.rb', line 4

def hash
  @hash
end

#originalObject (readonly)

Returns the value of attribute original.



5
6
7
# File 'lib/active_redis/dirty_objects/sorted_set.rb', line 5

def original
  @original
end

Instance Method Details

#[]=(score, value) ⇒ Object



7
8
9
10
11
# File 'lib/active_redis/dirty_objects/sorted_set.rb', line 7

def []=(score, value)
  self.push(score)
  @hash ||= {}
  @hash[value] = score
end

#changesObject



22
23
24
# File 'lib/active_redis/dirty_objects/sorted_set.rb', line 22

def changes
  super.merge(hash: @hash)
end

#replace(hash) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/active_redis/dirty_objects/sorted_set.rb', line 13

def replace(hash)
  @hash = hash
  self.clear
  hash.values.each do |value|
    self.push(value)
  end
  hash
end