Sha256: 3ba9bd091a09448e5d73b68c824e111f6ba2a7ee906e87cc20001cde1dae519c

Contents?: true

Size: 652 Bytes

Versions: 194

Compression:

Stored size: 652 Bytes

Contents

# frozen_string_literal: true

module ActiveRecord
  module Type
    class Json < ActiveModel::Type::Value
      include ActiveModel::Type::Helpers::Mutable

      def type
        :json
      end

      def deserialize(value)
        return value unless value.is_a?(::String)
        ActiveSupport::JSON.decode(value) rescue nil
      end

      def serialize(value)
        ActiveSupport::JSON.encode(value) unless value.nil?
      end

      def changed_in_place?(raw_old_value, new_value)
        deserialize(raw_old_value) != new_value
      end

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

Version data entries

194 entries across 189 versions & 17 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/activerecord-7.0.8.7/lib/active_record/type/json.rb
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/activerecord-7.1.3.4/lib/active_record/type/json.rb
activerecord-8.0.1 lib/active_record/type/json.rb
activerecord-8.0.0.1 lib/active_record/type/json.rb
activerecord-7.2.2.1 lib/active_record/type/json.rb
activerecord-7.1.5.1 lib/active_record/type/json.rb
activerecord-7.0.8.7 lib/active_record/type/json.rb
activerecord-8.0.0 lib/active_record/type/json.rb
activerecord-7.2.2 lib/active_record/type/json.rb
activerecord-7.1.5 lib/active_record/type/json.rb
activerecord-8.0.0.rc2 lib/active_record/type/json.rb
activerecord-7.2.1.2 lib/active_record/type/json.rb
activerecord-7.1.4.2 lib/active_record/type/json.rb
activerecord-7.0.8.6 lib/active_record/type/json.rb
activerecord-6.1.7.10 lib/active_record/type/json.rb
activerecord-8.0.0.rc1 lib/active_record/type/json.rb
activerecord-6.1.7.9 lib/active_record/type/json.rb
activerecord-7.2.1.1 lib/active_record/type/json.rb
activerecord-7.1.4.1 lib/active_record/type/json.rb
activerecord-7.0.8.5 lib/active_record/type/json.rb