class Perpetuity::Postgres::JSONArray
Public Class Methods
new(value, position=:outer)
click to toggle source
# File lib/perpetuity/postgres/json_array.rb, line 7 def initialize value, position=:outer @value = value @position = position end
Public Instance Methods
serialize_elements()
click to toggle source
# File lib/perpetuity/postgres/json_array.rb, line 24 def serialize_elements @value.map do |element| if element.is_a? String JSONStringValue.new(element) else SQLValue.new(element) end end.join(',') end
to_a()
click to toggle source
# File lib/perpetuity/postgres/json_array.rb, line 34 def to_a @value end
to_inner_array()
click to toggle source
# File lib/perpetuity/postgres/json_array.rb, line 20 def to_inner_array "[#{serialize_elements}]" end
to_s()
click to toggle source
# File lib/perpetuity/postgres/json_array.rb, line 12 def to_s if @position == :outer "'#{to_inner_array}'" else to_inner_array end end