Class: Ohm::SortedSet
- Inherits:
-
Model::Collection
- Object
- Model::Collection
- Ohm::SortedSet
show all
- Includes:
- SortedMethods
- Defined in:
- lib/ohm/sorted.rb,
lib/ohm/sorted.rb
Instance Attribute Summary
#key, #model, #namespace
Instance Method Summary
collapse
#between, #count, #first, #ids, #initialize, #inspect, #offset, #reverse, #reversed?, #size, #slice
Instance Method Details
#[](id) ⇒ Object
116
117
118
|
# File 'lib/ohm/sorted.rb', line 116
def [](id)
model[id] if !!db.zrank(key, id)
end
|
#all ⇒ Object
124
125
126
|
# File 'lib/ohm/sorted.rb', line 124
def all
ids.map(&model)
end
|
#db ⇒ Object
96
97
98
|
# File 'lib/ohm/sorted.rb', line 96
def db
model.db
end
|
#each ⇒ Object
108
109
110
111
112
113
114
|
# File 'lib/ohm/sorted.rb', line 108
def each
if block_given?
ids.each { |id| block.call(model.to_proc[id]) }
else
to_enum(:each)
end
end
|
#empty? ⇒ Boolean
120
121
122
|
# File 'lib/ohm/sorted.rb', line 120
def empty?
size == 0
end
|
#include?(model) ⇒ Boolean
128
129
130
|
# File 'lib/ohm/sorted.rb', line 128
def include?(model)
!!db.zrank(key, model.id)
end
|