Module: ROM::SQL::Postgres::Types::JSONMethods

Defined in:
lib/rom/sql/extensions/postgres/types/json.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.[](type, wrap) ⇒ Object


224
225
226
227
228
229
230
231
# File 'lib/rom/sql/extensions/postgres/types/json.rb', line 224

def self.[](type, wrap)
  parent = self
  Module.new do
    include parent
    define_method(:json_type) { type }
    define_method(:wrap, wrap)
  end
end

Instance Method Details

#get(_type, expr, *path) ⇒ Object


233
234
235
# File 'lib/rom/sql/extensions/postgres/types/json.rb', line 233

def get(_type, expr, *path)
  Attribute[json_type].meta(sql_expr: wrap(expr)[path_args(path)])
end

#get_text(_type, expr, *path) ⇒ Object


237
238
239
# File 'lib/rom/sql/extensions/postgres/types/json.rb', line 237

def get_text(_type, expr, *path)
  Attribute[SQL::Types::String].meta(sql_expr: wrap(expr).get_text(path_args(path)))
end