Module: MemDB::Idx

Included in:
Bytes, Chars, Default, Downcase, Itself, Pattern, Reverse, Uniq
Defined in:
lib/mem_db/idx.rb,
lib/mem_db/idx/uniq.rb,
lib/mem_db/idx/bytes.rb,
lib/mem_db/idx/chars.rb,
lib/mem_db/idx/itself.rb,
lib/mem_db/idx/default.rb,
lib/mem_db/idx/pattern.rb,
lib/mem_db/idx/reverse.rb,
lib/mem_db/idx/downcase.rb

Defined Under Namespace

Classes: Bytes, Chars, Default, Downcase, Itself, Pattern, Reverse, Uniq

Constant Summary collapse

ANY =
Object.new

Instance Method Summary collapse

Instance Method Details

#default(default) ⇒ Object



7
8
9
# File 'lib/mem_db/idx.rb', line 7

def default(default)
  MemDB::Idx::Default.new(self, default)
end

#default_anyObject



11
12
13
# File 'lib/mem_db/idx.rb', line 11

def default_any
  default(MemDB::Idx::ANY)
end

#downcaseObject



15
16
17
# File 'lib/mem_db/idx.rb', line 15

def downcase
  MemDB::Idx::Downcase.new(self)
end

#fieldObject

Raises:

  • (NotImplementedError)


19
20
21
# File 'lib/mem_db/idx.rb', line 19

def field
  raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'"
end

#map_query(_obj) ⇒ Object

Raises:

  • (NotImplementedError)


27
28
29
# File 'lib/mem_db/idx.rb', line 27

def map_query(_obj)
  raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'"
end

#map_value(_obj) ⇒ Object

Raises:

  • (NotImplementedError)


23
24
25
# File 'lib/mem_db/idx.rb', line 23

def map_value(_obj)
  raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'"
end

#prepare_query(query) ⇒ Object



41
42
43
# File 'lib/mem_db/idx.rb', line 41

def prepare_query(query)
  query[field].map { |v| map_query(v) }
end

#value(obj) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/mem_db/idx.rb', line 31

def value(obj)
  v = obj[field]

  if v == ANY
    v
  else
    v.map { |e| map_value(e) }
  end
end