Class: Perpetuity::Postgres::SQLValue
- Inherits:
-
Object
- Object
- Perpetuity::Postgres::SQLValue
- Defined in:
- lib/perpetuity/postgres/sql_value.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(value) ⇒ SQLValue
constructor
A new instance of SQLValue.
- #to_s ⇒ Object
Constructor Details
#initialize(value) ⇒ SQLValue
Returns a new instance of SQLValue.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/perpetuity/postgres/sql_value.rb', line 15 def initialize value @value = case value when String, Symbol TextValue.new(value) when Time TimestampValue.new(value) when Date DateValue.new(value) when Fixnum, Float NumericValue.new(value) when Hash, JSONHash JSONHash.new(value.to_hash, :inner) when Array, JSONArray JSONArray.new(value.to_a, :inner) when nil NullValue.new when true, false BooleanValue.new(value) end.to_s end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
13 14 15 |
# File 'lib/perpetuity/postgres/sql_value.rb', line 13 def value @value end |
Instance Method Details
#==(other) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/perpetuity/postgres/sql_value.rb', line 40 def == other if other.is_a? String value == other else value == other.value end end |
#to_s ⇒ Object
36 37 38 |
# File 'lib/perpetuity/postgres/sql_value.rb', line 36 def to_s value end |