Class: MemDB::Idx::Default

Inherits:
Object
  • Object
show all
Includes:
MemDB::Idx
Defined in:
lib/mem_db/idx/default.rb

Constant Summary

Constants included from MemDB::Idx

ANY

Instance Method Summary collapse

Methods included from MemDB::Idx

#default, #default_any, #downcase, #map_query, #map_value

Constructor Details

#initialize(original, default) ⇒ Default

Returns a new instance of Default.



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

def initialize(original, default)
  @original = original
  @default = default
end

Instance Method Details

#fieldObject



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

def field
  @original.field
end

#prepare_query(query) ⇒ Object



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

def prepare_query(query)
  @original.prepare_query(query)
end

#value(obj) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/mem_db/idx/default.rb', line 19

def value(obj)
  v = obj[field]
  if v.nil?
    @default
  else
    @original.value(obj)
  end
end