Class: Types::PgJsonb
- Inherits:
-
Object
- Object
- Types::PgJsonb
- Defined in:
- lib/kweerie/types/pg_jsonb.rb
Instance Method Summary collapse
Instance Method Details
#cast(value) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/kweerie/types/pg_jsonb.rb', line 5 def cast(value) return {} if value.nil? return value if value.is_a?(Hash) JSON.parse(value.to_s) rescue JSON::ParserError raise ArgumentError, "Invalid JSON value: #{value}" end |