Class: Ohm::SortedSet

Inherits:
Model::Collection
  • Object
show all
Includes:
SortedMethods
Defined in:
lib/ohm/sorted.rb,
lib/ohm/sorted.rb

Direct Known Subclasses

RangedSortedSet

Instance Attribute Summary

Attributes included from SortedMethods

#key, #model, #namespace

Instance Method Summary collapse

Methods included from SortedMethods

#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

#allObject



126
127
128
# File 'lib/ohm/sorted.rb', line 126

def all
  ids.map(&model)
end

#dbObject



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

Returns:

  • (Boolean)


122
123
124
# File 'lib/ohm/sorted.rb', line 122

def empty?
  size == 0
end

#include?(model) ⇒ Boolean

Returns:

  • (Boolean)


130
131
132
# File 'lib/ohm/sorted.rb', line 130

def include?(model)
  !!db.zrank(key, model.id)
end