Class: Findable::Schema::Conversion

Inherits:
Object
  • Object
show all
Defined in:
lib/findable/schema/conversion.rb

Constant Summary collapse

FALSE_VALUE =
["false", "0"]

Class Method Summary collapse

Class Method Details

.add_type!(type) ⇒ Object



18
19
20
21
# File 'lib/findable/schema/conversion.rb', line 18

def add_type!(type)
  return type if type.respond_to?(:call)
  types[type.to_sym] = method(type)
end

.clear_typesObject



23
24
25
# File 'lib/findable/schema/conversion.rb', line 23

def clear_types
  @_types = nil
end

.for(type) ⇒ Object



7
8
9
10
# File 'lib/findable/schema/conversion.rb', line 7

def for(type)
  return types[:default] if type.nil?
  types[type] || add_type!(type)
end

.typesObject



12
13
14
15
16
# File 'lib/findable/schema/conversion.rb', line 12

def types
  @_types ||= {
    default: Proc.new {|value| value }
  }
end