Sha256: d7dff83611202c35fea5845bfa8ff407099e4fba9d6a3230041d33b43ddc93a3

Contents?: true

Size: 388 Bytes

Versions: 15

Compression:

Stored size: 388 Bytes

Contents

module ActiveRemote
  module Typecasting
    class BooleanTypecaster
       FALSE_VALUES = ["n", "N", "no", "No", "NO", "false", "False", "FALSE", "off", "Off", "OFF", "f", "F"]

      def self.call(value)
        case value
        when *FALSE_VALUES then false
        when Numeric, /^\-?[0-9]/ then !value.to_f.zero?
        else value.present?
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
active_remote-3.2.1 lib/active_remote/typecasting/boolean_typecaster.rb
active_remote-3.2.0 lib/active_remote/typecasting/boolean_typecaster.rb
active_remote-3.2.0.pre lib/active_remote/typecasting/boolean_typecaster.rb
active_remote-3.1.3 lib/active_remote/typecasting/boolean_typecaster.rb
active_remote-3.1.2 lib/active_remote/typecasting/boolean_typecaster.rb
active_remote-3.1.2.pre lib/active_remote/typecasting/boolean_typecaster.rb
active_remote-3.1.1 lib/active_remote/typecasting/boolean_typecaster.rb
active_remote-3.1.0 lib/active_remote/typecasting/boolean_typecaster.rb
active_remote-3.0.0 lib/active_remote/typecasting/boolean_typecaster.rb
active_remote-3.0.0.pre1 lib/active_remote/typecasting/boolean_typecaster.rb
active_remote-2.4.0 lib/active_remote/typecasting/boolean_typecaster.rb
active_remote-2.3.5 lib/active_remote/typecasting/boolean_typecaster.rb
active_remote-2.3.4 lib/active_remote/typecasting/boolean_typecaster.rb
active_remote-2.3.3 lib/active_remote/typecasting/boolean_typecaster.rb
active_remote-2.3.3.pre lib/active_remote/typecasting/boolean_typecaster.rb