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

Inherits:
Type::Value
  • Object
show all
Defined in:
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



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/active_record/connection_adapters/postgresql/oid/bit.rb', line 10

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



23
24
25
# File 'lib/active_record/connection_adapters/postgresql/oid/bit.rb', line 23

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

#typeObject



6
7
8
# File 'lib/active_record/connection_adapters/postgresql/oid/bit.rb', line 6

def type
  :bit
end