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.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/perpetuity/postgres/sql_value.rb', line 14 def initialize value @value = case value when String, Symbol TextValue.new(value) when Time TimestampValue.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.
12 13 14 |
# File 'lib/perpetuity/postgres/sql_value.rb', line 12 def value @value end |
Instance Method Details
#==(other) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/perpetuity/postgres/sql_value.rb', line 37 def == other if other.is_a? String value == other else value == other.value end end |
#to_s ⇒ Object
33 34 35 |
# File 'lib/perpetuity/postgres/sql_value.rb', line 33 def to_s value end |