Sha256: 2ae5a36656248f7a50b30e24e53bb0324393df9dff13b0ff5e58b4480ea5040d

Contents?: true

Size: 404 Bytes

Versions: 3

Compression:

Stored size: 404 Bytes

Contents

# frozen_string_literal: true

module Attribeauty
  module Types
    # custom boolean type
    class Boolean
      FALSE_VALUES = [
        false, 0,
        "0", :"0",
        "f", :f,
        "F", :F,
        "false", false,
        "FALSE", :FALSE,
        "off", :off,
        "OFF", :OFF
      ].to_set.freeze

      def cast(value)
        !FALSE_VALUES.include?(value)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
attribeauty-0.3.2 lib/attribeauty/types/boolean.rb
attribeauty-0.3.1 lib/attribeauty/types/boolean.rb
attribeauty-0.3.0 lib/attribeauty/types/boolean.rb