Class: Perpetuity::Postgres::JSONStringValue

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

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ JSONStringValue

Returns a new instance of JSONStringValue.



4
5
6
7
8
9
# File 'lib/perpetuity/postgres/json_string_value.rb', line 4

def initialize value
  @value = value
    .to_s
    .gsub('"') { '\\"' }
    .gsub("'") { "''" }
end

Instance Method Details

#to_sObject



11
12
13
# File 'lib/perpetuity/postgres/json_string_value.rb', line 11

def to_s
  %Q{"#{@value}"}
end

#to_strObject



15
16
17
# File 'lib/perpetuity/postgres/json_string_value.rb', line 15

def to_str
  to_s
end