Class: ActiveRecord::Type::Spanner::Bytes

Inherits:
Binary
  • Object
show all
Defined in:
lib/active_record/type/spanner/bytes.rb

Instance Method Summary collapse

Instance Method Details

#serialize(value) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/active_record/type/spanner/bytes.rb', line 13

def serialize value
  return super value if value.nil?

  if value.respond_to?(:read) && value.respond_to?(:rewind)
    value.rewind
    value = value.read
  end

  Base64.strict_encode64 value.force_encoding("ASCII-8BIT")
end