Sha256: a8fc10138e782811cc1ea94941c24939c701720ed09b4926bef41770f2de4a9d

Contents?: true

Size: 405 Bytes

Versions: 2

Compression:

Stored size: 405 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

2 entries across 2 versions & 1 rubygems

Version Path
attribeauty-0.2.0 lib/attribeauty/types/boolean.rb
attribeauty-0.1.0 lib/attribeauty/types/boolean.rb