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
118
119
120
|
# File 'lib/ohm/sorted.rb', line 118
def [](id)
model[id] if !!db.zrank(key, id)
end
|
#all ⇒ Object
126
127
128
|
# File 'lib/ohm/sorted.rb', line 126
def all
ids.map(&model)
end
|
#db ⇒ Object
101
102
103
|
# File 'lib/ohm/sorted.rb', line 101
def db
model.db
end
|
#each(&block) ⇒ Object
113
114
115
116
|
# File 'lib/ohm/sorted.rb', line 113
def each(&block)
return to_enum(:each) unless block
ids.each { |id| block.call(model.to_proc[id]) }
end
|
#empty? ⇒ Boolean
122
123
124
|
# File 'lib/ohm/sorted.rb', line 122
def empty?
size == 0
end
|
#include?(model) ⇒ Boolean
130
131
132
|
# File 'lib/ohm/sorted.rb', line 130
def include?(model)
!!db.zrank(key, model.id)
end
|