Module: JunglePath::DBAccess::IO::InitDB
- Defined in:
- lib/jungle_path/db_access/io/init_db.rb
Instance Method Summary collapse
Instance Method Details
#handle_json_columns(model, hash) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# 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 |
#initialize(db, logger = nil) ⇒ Object
7 8 9 10 |
# File 'lib/jungle_path/db_access/io/init_db.rb', line 7 def initialize(db, logger=nil) @db = db @logger = logger end |