Class: Db2Query::Type::String

Inherits:
Value
  • Object
show all
Defined in:
lib/db2_query/type/string.rb

Direct Known Subclasses

Text

Constant Summary collapse

DEFAULT =
{ trim: false }

Instance Attribute Summary

Attributes inherited from Value

#options

Instance Method Summary collapse

Methods inherited from Value

#quote, #serialize, #type_name

Constructor Details

#initialize(options = DEFAULT) ⇒ String

Returns a new instance of String.



8
9
10
# File 'lib/db2_query/type/string.rb', line 8

def initialize(options = DEFAULT)
  super(options)
end

Instance Method Details

#deserialize(value) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/db2_query/type/string.rb', line 16

def deserialize(value)
  value.strip! if options[:trim]
  case value
  when ::String then
    if value == "null"
      nil
    else
      ::String.new(value)
    end
  else value.to_s
  end
end

#typeObject



12
13
14
# File 'lib/db2_query/type/string.rb', line 12

def type
  :string
end