Class: Perpetuity::Postgres::JSONArray
- Inherits:
-
Object
- Object
- Perpetuity::Postgres::JSONArray
- Defined in:
- lib/perpetuity/postgres/json_array.rb
Instance Method Summary collapse
-
#initialize(value) ⇒ JSONArray
constructor
A new instance of JSONArray.
- #serialize_elements ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(value) ⇒ JSONArray
Returns a new instance of JSONArray.
8 9 10 |
# File 'lib/perpetuity/postgres/json_array.rb', line 8 def initialize value @value = value end |
Instance Method Details
#serialize_elements ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/perpetuity/postgres/json_array.rb', line 16 def serialize_elements @value.map do |element| if element.is_a? Numeric NumericValue.new(element) elsif element.is_a? String JSONStringValue.new(element) elsif element.is_a? Hash JSONHash.new(element, :inner) elsif element.is_a? JSONHash JSONHash.new(element.to_hash, :inner) end end.join(',') end |
#to_s ⇒ Object
12 13 14 |
# File 'lib/perpetuity/postgres/json_array.rb', line 12 def to_s "'[#{serialize_elements}]'" end |