module JunglePath::DBAccess::IO::InitDB
Public Class Methods
new(db, logger=nil)
click to toggle source
# File lib/jungle_path/db_access/io/init_db.rb, line 7 def initialize(db, logger=nil) @db = db @logger = logger end
Public Instance Methods
handle_json_columns(model, hash)
click to toggle source
# File lib/jungle_path/db_access/io/init_db.rb, line 12 def handle_json_columns(model, hash) new_hash = {} columns = model.class.columns hash.each do |key, value| if columns[key].type == :json unless value == nil #if value.class == String # must convert to hash... (assuming this is a string of json...) # value = JsonWrap.load value, {:mode => :compat, :symbol_keys => true, :indent=>0 } #end new_hash[key] = Sequel.pg_json(value) end elsif columns[key].type == :jsonb unless value == nil #if value.class == String # must convert to hash... (assuming this is a string of json...) # value = JsonWrap.load value, {:mode => :compat, :symbol_keys => true, :indent=>0 } #end new_hash[key] = Sequel.pg_jsonb(value) end else new_hash[key] = value unless value == nil end end new_hash end