Sha256: 46385873c42b5334ac73ace85d1e3964135f5a6cf4bdcc249ed0cfddc22efdbf

Contents?: true

Size: 685 Bytes

Versions: 35

Compression:

Stored size: 685 Bytes

Contents

module ActiveRecord
  module Type
    module Internal # :nodoc:
      class AbstractJson < ActiveModel::Type::Value # :nodoc:
        include ActiveModel::Type::Helpers::Mutable

        def type
          :json
        end

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

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

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

Version data entries

35 entries across 35 versions & 3 rubygems

Version Path
activerecord-5.0.7.2 lib/active_record/type/internal/abstract_json.rb
activerecord-5.0.7.1 lib/active_record/type/internal/abstract_json.rb
activerecord-5.0.7 lib/active_record/type/internal/abstract_json.rb
activerecord-5.0.6 lib/active_record/type/internal/abstract_json.rb
activerecord-5.0.6.rc1 lib/active_record/type/internal/abstract_json.rb
activerecord-5.1.3 lib/active_record/type/internal/abstract_json.rb
activerecord-5.1.3.rc3 lib/active_record/type/internal/abstract_json.rb
activerecord-5.0.5 lib/active_record/type/internal/abstract_json.rb
activerecord-5.0.5.rc2 lib/active_record/type/internal/abstract_json.rb
activerecord-5.1.3.rc2 lib/active_record/type/internal/abstract_json.rb
activerecord-5.0.5.rc1 lib/active_record/type/internal/abstract_json.rb
activerecord-5.1.3.rc1 lib/active_record/type/internal/abstract_json.rb
activerecord-5.1.2 lib/active_record/type/internal/abstract_json.rb
activerecord-5.1.2.rc1 lib/active_record/type/internal/abstract_json.rb
activerecord-5.0.4 lib/active_record/type/internal/abstract_json.rb
activerecord-5.0.4.rc1 lib/active_record/type/internal/abstract_json.rb
activerecord-5.1.1 lib/active_record/type/internal/abstract_json.rb
activerecord-5.0.3 lib/active_record/type/internal/abstract_json.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/activerecord-5.0.2/lib/active_record/type/internal/abstract_json.rb
activerecord-5.1.0 lib/active_record/type/internal/abstract_json.rb