Sha256: 9cdb7def11bfa04f7ce71a1972c00d901eb7d4b116b5f3a723a55d3e2fae2249

Contents?: true

Size: 372 Bytes

Versions: 38

Compression:

Stored size: 372 Bytes

Contents

module ActiveModel
  module Type
    class Boolean < Value # :nodoc:
      FALSE_VALUES = [false, 0, '0', 'f', 'F', 'false', 'FALSE', 'off', 'OFF'].to_set

      def type
        :boolean
      end

      private

      def cast_value(value)
        if value == ''
          nil
        else
          !FALSE_VALUES.include?(value)
        end
      end
    end
  end
end

Version data entries

38 entries across 37 versions & 5 rubygems

Version Path
activemodel-5.0.7.2 lib/active_model/type/boolean.rb
activemodel-5.0.7.1 lib/active_model/type/boolean.rb
activemodel-5.0.7 lib/active_model/type/boolean.rb
activemodel-5.0.6 lib/active_model/type/boolean.rb
activemodel-5.0.6.rc1 lib/active_model/type/boolean.rb
activemodel-5.0.5 lib/active_model/type/boolean.rb
activemodel-5.0.5.rc2 lib/active_model/type/boolean.rb
activemodel-5.0.5.rc1 lib/active_model/type/boolean.rb
tdiary-5.0.5 vendor/bundle/gems/activemodel-5.0.2/lib/active_model/type/boolean.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/activemodel-5.0.2/lib/active_model/type/boolean.rb
activemodel-5.0.4 lib/active_model/type/boolean.rb
activemodel-5.0.4.rc1 lib/active_model/type/boolean.rb
activemodel-5.0.3 lib/active_model/type/boolean.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/activemodel-5.0.2/lib/active_model/type/boolean.rb
tdiary-5.0.4 vendor/bundle/gems/activemodel-5.0.2/lib/active_model/type/boolean.rb
activemodel-5.0.2 lib/active_model/type/boolean.rb
activemodel-5.0.2.rc1 lib/active_model/type/boolean.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/activemodel-5.0.1/lib/active_model/type/boolean.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/activemodel-5.0.1/lib/active_model/type/boolean.rb
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/activemodel-5.0.1/lib/active_model/type/boolean.rb