Class: Torque::PostgreSQL::Adapter::OID::StructSet

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

Instance Method Summary collapse

Instance Method Details

#blank_documentObject



31
32
33
# File 'lib/torque/postgresql/adapter/oid/struct_set.rb', line 31

def blank_document
  []
end

#changed_in_place?(raw_old_value, new_value) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
# File 'lib/torque/postgresql/adapter/oid/struct_set.rb', line 17

def changed_in_place?(raw_old_value, new_value)
  Struct.state(without_backfill.deserialize(raw_old_value)) !=
    Struct.state(new_value)
end

#deserialize(value) ⇒ Object



8
9
10
# File 'lib/torque/postgresql/adapter/oid/struct_set.rb', line 8

def deserialize(value)
  value.nil? ? [] : super
end

#empty?(value) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/torque/postgresql/adapter/oid/struct_set.rb', line 27

def empty?(value)
  value.is_a?(::Array) ? value.empty? : subtype.empty?(value)
end

#serialize(value) ⇒ Object



12
13
14
15
# File 'lib/torque/postgresql/adapter/oid/struct_set.rb', line 12

def serialize(value)
  return if value.is_a?(::Array) && value.empty?
  super
end

#without_backfillObject



22
23
24
25
# File 'lib/torque/postgresql/adapter/oid/struct_set.rb', line 22

def without_backfill
  return self if subtype.backfill.nil?
  @without_backfill ||= self.class.new(subtype.without_backfill, delimiter)
end