Class: Gitlab::Database::Type::IndifferentJsonb

Inherits:
ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Jsonb
  • Object
show all
Defined in:
lib/gitlab/database/type/indifferent_jsonb.rb

Overview

Extends Rails’ Jsonb data type to deserialize it into indifferent access Hash.

Example:

class SomeModel < ApplicationRecord
  # some_model.a_field is of type `jsonb`
  attribute :a_field, :ind_jsonb
end

Instance Method Summary collapse

Instance Method Details

#deserialize(value) ⇒ Object



19
20
21
22
23
24
# File 'lib/gitlab/database/type/indifferent_jsonb.rb', line 19

def deserialize(value)
  data = super
  return unless data

  ::Gitlab::Utils.deep_indifferent_access(data)
end

#typeObject



15
16
17
# File 'lib/gitlab/database/type/indifferent_jsonb.rb', line 15

def type
  :ind_jsonb
end