Class: Rasti::DB::TypeConverters::PostgresTypes::HStore
- Inherits:
-
Object
- Object
- Rasti::DB::TypeConverters::PostgresTypes::HStore
- Defined in:
- lib/rasti/db/type_converters/postgres_types/hstore.rb
Constant Summary collapse
- DB_TYPE_REGEX =
/^hstore$/
Class Method Summary collapse
- .from_db(value) ⇒ Object
- .from_db?(klass) ⇒ Boolean
- .to_db(value, type) ⇒ Object
- .to_db?(type) ⇒ Boolean
Class Method Details
.from_db(value) ⇒ Object
23 24 25 |
# File 'lib/rasti/db/type_converters/postgres_types/hstore.rb', line 23 def from_db(value) value.to_h end |
.from_db?(klass) ⇒ Boolean
18 19 20 21 |
# File 'lib/rasti/db/type_converters/postgres_types/hstore.rb', line 18 def from_db?(klass) defined?(Sequel::Postgres::HStore) && klass == Sequel::Postgres::HStore end |
.to_db(value, type) ⇒ Object
14 15 16 |
# File 'lib/rasti/db/type_converters/postgres_types/hstore.rb', line 14 def to_db(value, type) Sequel.hstore value end |
.to_db?(type) ⇒ Boolean
10 11 12 |
# File 'lib/rasti/db/type_converters/postgres_types/hstore.rb', line 10 def to_db?(type) !type.match(DB_TYPE_REGEX).nil? end |