Class: ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Bit

Inherits:
Type::Value
  • Object
show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/connection_adapters/postgresql/oid/bit.rb

Overview

:nodoc:

Direct Known Subclasses

BitVarying

Defined Under Namespace

Classes: Data

Instance Method Summary collapse

Instance Method Details

#cast_value(value) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/connection_adapters/postgresql/oid/bit.rb', line 12

def cast_value(value)
  if ::String === value
    case value
    when /^0x/i
      value[2..-1].hex.to_s(2) # Hexadecimal notation
    else
      value                    # Bit-string notation
    end
  else
    value.to_s
  end
end

#serialize(value) ⇒ Object



25
26
27
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/connection_adapters/postgresql/oid/bit.rb', line 25

def serialize(value)
  Data.new(super) if value
end

#typeObject



8
9
10
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/connection_adapters/postgresql/oid/bit.rb', line 8

def type
  :bit
end