Class: ActiveModel::Type::Binary::Data

Inherits:
Object
  • Object
show all
Defined in:
lib/active_model/type/binary.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Data

Returns a new instance of Data.



33
34
35
36
37
# File 'lib/active_model/type/binary.rb', line 33

def initialize(value)
  value = value.to_s
  value = value.b unless value.encoding == Encoding::BINARY
  @value = value
end

Instance Method Details

#==(other) ⇒ Object



48
49
50
# File 'lib/active_model/type/binary.rb', line 48

def ==(other)
  other == to_s || super
end

#hexObject



44
45
46
# File 'lib/active_model/type/binary.rb', line 44

def hex
  @value.unpack1("H*")
end

#to_sObject Also known as: to_str



39
40
41
# File 'lib/active_model/type/binary.rb', line 39

def to_s
  @value
end