Class: DataMapper::Property::BinaryString

Inherits:
Text
  • Object
show all
Defined in:
lib/types/tuple.rb,
lib/types/binary_string.rb

Instance Method Summary collapse

Instance Method Details

#custom?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/types/tuple.rb', line 6

def custom?
  true
end

#dump(value) ⇒ Object



27
28
29
# File 'lib/types/binary_string.rb', line 27

def dump(value)
   "<<\"#{value.to_s}\">>"
end

#load(value) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/types/binary_string.rb', line 16

def load(value)
  if value.nil?
    nil
  elsif value.is_a?(::String)
    value
  else
    raise ArgumentError.new("not sure what type #{value.class}")
  end
end

#primitive?(value) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/types/binary_string.rb', line 8

def primitive?(value)
  value.kind_of?(::String) 
end

#typecast_to_primitive(value) ⇒ Object



31
32
33
# File 'lib/types/binary_string.rb', line 31

def typecast_to_primitive(value)
  value.to_s
end

#valid?(value, negated = false) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/types/binary_string.rb', line 12

def valid?(value, negated = false)
  super || dump(value).kind_of?(::String)
end