Class: Torque::PostgreSQL::Adapter::OID::Lquery

Inherits:
ActiveModel::Type::Value
  • Object
show all
Defined in:
lib/torque/postgresql/adapter/oid/lquery.rb

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Object Also known as: eql?

Types resolved through the type map are deduplicated and frozen, so they need to be comparable



40
41
42
# File 'lib/torque/postgresql/adapter/oid/lquery.rb', line 40

def ==(other)
  other.is_a?(self.class)
end

#cast(value) ⇒ Object



13
14
15
16
17
18
# File 'lib/torque/postgresql/adapter/oid/lquery.rb', line 13

def cast(value)
  return if value.blank?
  return value if value.is_a?(LQuery)

  LQuery.new(value)
end

#changed_in_place?(raw_old_value, new_value) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/torque/postgresql/adapter/oid/lquery.rb', line 34

def changed_in_place?(raw_old_value, new_value)
  raw_old_value != serialize(new_value)
end

#deserialize(value) ⇒ Object



20
21
22
23
24
# File 'lib/torque/postgresql/adapter/oid/lquery.rb', line 20

def deserialize(value)
  return if value.nil?

  LQuery.load(value)
end

#hashObject



45
46
47
# File 'lib/torque/postgresql/adapter/oid/lquery.rb', line 45

def hash
  self.class.hash
end

#serialize(value) ⇒ Object



26
27
28
# File 'lib/torque/postgresql/adapter/oid/lquery.rb', line 26

def serialize(value)
  cast(value)&.to_s
end

#typeObject



9
10
11
# File 'lib/torque/postgresql/adapter/oid/lquery.rb', line 9

def type
  :lquery
end

#type_cast_for_schema(value) ⇒ Object



30
31
32
# File 'lib/torque/postgresql/adapter/oid/lquery.rb', line 30

def type_cast_for_schema(value)
  cast(value).to_s.inspect
end