Sha256: 6a3e1413f5d36f392f6c640fba3f8848b494cd1bed045a5bfc63351784ea00cd

Contents?: true

Size: 614 Bytes

Versions: 6

Compression:

Stored size: 614 Bytes

Contents

# frozen_string_literal: true

module ActiverecordAccessibleJson
  #:nodoc:
  module JsonExtension
    # This patch is strongly dependent with ActiveRecord::Type::Json implementation.
    # https://github.com/rails/rails/blob/8b3fc5ce30629cb098e923396c3eb797365c88d2/activerecord/lib/active_record/type/json.rb#L12
    def deserialize(value)
      return value unless value.is_a?(::String)

      decoded_value = ActiveSupport::JSON.decode(value)
      decoded_value.respond_to?(:with_indifferent_access) ? decoded_value.with_indifferent_access : decoded_value
    rescue StandardError
      nil
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
activerecord_accessible_json-0.3.7 lib/activerecord_accessible_json/json_extension.rb
activerecord_accessible_json-0.3.6 lib/activerecord_accessible_json/json_extension.rb
activerecord_accessible_json-0.3.5 lib/activerecord_accessible_json/json_extension.rb
activerecord_accessible_json-0.3.4 lib/activerecord_accessible_json/json_extension.rb
activerecord_accessible_json-0.3.2 lib/activerecord_accessible_json/json_extension.rb
activerecord_accessible_json-0.3.1 lib/activerecord_accessible_json/json_extension.rb