Class: Torque::PostgreSQL::Adapter::OID::Range

Inherits:
ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Range
  • Object
show all
Defined in:
lib/torque/postgresql/adapter/oid/range.rb

Defined Under Namespace

Modules: Comparasion

Constant Summary collapse

HASH_PICK =
%i[from start end to].freeze

Instance Method Summary collapse

Instance Method Details

#cast_value(value) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/torque/postgresql/adapter/oid/range.rb', line 16

def cast_value(value)
  case value
  when Array
    cast_custom(value[0], value[1])
  when Hash
    pieces = value.with_indifferent_access.values_at(*HASH_PICK)
    cast_custom(pieces[0] || pieces[1], pieces[2] || pieces[3])
  else
    super
  end
end

#map(value) ⇒ Object

:nodoc:



28
29
30
31
32
33
# File 'lib/torque/postgresql/adapter/oid/range.rb', line 28

def map(value) # :nodoc:
  return value unless value.respond_to?(:first)
  from = yield(value.first)
  to = yield(value.last)
  cast_custom(from, to)
end