Class: Perpetuity::Postgres::SQLValue

Inherits:
Object
  • Object
show all
Defined in:
lib/perpetuity/postgres/sql_value.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ SQLValue

Returns a new instance of SQLValue.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/perpetuity/postgres/sql_value.rb', line 12

def initialize value
  @value = case value
           when String, Symbol
             TextValue.new(value)
           when Time
             TimestampValue.new(value)
           when Fixnum, Float
             NumericValue.new(value)
           when nil
             NullValue.new
           when true, false
             BooleanValue.new(value)
           end.to_s
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



10
11
12
# File 'lib/perpetuity/postgres/sql_value.rb', line 10

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/perpetuity/postgres/sql_value.rb', line 31

def == other
  if other.is_a? String
    value == other
  else
    value == other.value
  end
end

#to_sObject



27
28
29
# File 'lib/perpetuity/postgres/sql_value.rb', line 27

def to_s
  value
end