aboutsummaryrefslogblamecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/postgresql/oid/hstore.rb
blob: 88de816d4f9f6598d9db6ebb1441801d3cad5030 (plain) (tree)
1
2
3
4
5
6
7
8
9








                                  
                                        
                                                                  

             

                                                                        

             

                                                                        









                                                        
module ActiveRecord
  module ConnectionAdapters
    module PostgreSQL
      module OID # :nodoc:
        class Hstore < Type::Value
          def type
            :hstore
          end

          def type_cast_from_user(value)
            type_cast_from_database(type_cast_for_database(value))
          end

          def type_cast_from_database(value)
            ConnectionAdapters::PostgreSQLColumn.string_to_hstore(value)
          end

          def type_cast_for_database(value)
            ConnectionAdapters::PostgreSQLColumn.hstore_to_string(value)
          end

          def accessor
            ActiveRecord::Store::StringKeyedHashAccessor
          end
        end
      end
    end
  end
end