Sha256: fcb3d4233584f5732f563e357dc5fc272bb98cafe53acd58d98669ef11c88032

Contents?: true

Size: 915 Bytes

Versions: 16

Compression:

Stored size: 915 Bytes

Contents

module ActiveRecord
  module Type
    class Boolean < Value # :nodoc:
      def type
        :boolean
      end

      private

      def cast_value(value)
        if value == ''
          nil
        elsif ConnectionAdapters::Column::TRUE_VALUES.include?(value)
          true
        else
          if !ConnectionAdapters::Column::FALSE_VALUES.include?(value)
            ActiveSupport::Deprecation.warn(<<-MSG.squish)
              You attempted to assign a value which is not explicitly `true` or `false`
              to a boolean column. Currently this value casts to `false`. This will
              change to match Ruby's semantics, and will cast to `true` in Rails 5.
              If you would like to maintain the current behavior, you should
              explicitly handle the values you would like cast to `false`.
            MSG
          end
          false
        end
      end
    end
  end
end

Version data entries

16 entries across 15 versions & 4 rubygems

Version Path
activejob-lock-0.0.2 rails/activerecord/lib/active_record/type/boolean.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/activerecord-4.2.2/lib/active_record/type/boolean.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/activerecord-4.2.1/lib/active_record/type/boolean.rb
activerecord-4.2.2 lib/active_record/type/boolean.rb
shoppe-paypal-1.1.0 vendor/bundle/ruby/2.1.0/gems/activerecord-4.2.1/lib/active_record/type/boolean.rb
activerecord-4.2.1 lib/active_record/type/boolean.rb
activerecord-4.2.1.rc4 lib/active_record/type/boolean.rb
activerecord-4.2.1.rc3 lib/active_record/type/boolean.rb
activerecord-4.2.1.rc2 lib/active_record/type/boolean.rb
activerecord-4.2.1.rc1 lib/active_record/type/boolean.rb
activejob-lock-0.0.1 rails/activerecord/lib/active_record/type/boolean.rb
activerecord-4.2.0 lib/active_record/type/boolean.rb
activerecord-4.2.0.rc3 lib/active_record/type/boolean.rb
activerecord-4.2.0.rc2 lib/active_record/type/boolean.rb
activerecord-4.2.0.rc1 lib/active_record/type/boolean.rb
activerecord-4.2.0.beta4 lib/active_record/type/boolean.rb