123456789_123456789_123456789_123456789_123456789_

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

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
Defined in: activemodel/lib/active_model/type/binary.rb

Class Method Summary

Instance Method Summary

Constructor Details

.new(value) ⇒ Data

[ GitHub ]

  
# File 'activemodel/lib/active_model/type/binary.rb', line 43

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

Instance Method Details

#==(other)

[ GitHub ]

  
# File 'activemodel/lib/active_model/type/binary.rb', line 62

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

#as_json(options = nil)

[ GitHub ]

  
# File 'activemodel/lib/active_model/type/binary.rb', line 54

def as_json(options = nil)
  @value.as_json(options)
end

#hex

[ GitHub ]

  
# File 'activemodel/lib/active_model/type/binary.rb', line 58

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

#to_s Also known as: #to_str

[ GitHub ]

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

def to_s
  @value
end

#to_str

Alias for #to_s.

[ GitHub ]

  
# File 'activemodel/lib/active_model/type/binary.rb', line 52

alias_method :to_str, :to_s