Sha256: 3458fe7d30f9ad3500c0a4cd1aa83bedb0678cf7da1144dc8934ab6530b18419

Contents?: true

Size: 566 Bytes

Versions: 7

Compression:

Stored size: 566 Bytes

Contents

# encoding: utf-8

module Mixture
  module Types
    # The boolean type.  Unfortunately, ruby doesn't have a clear cut
    # boolean primitive (it has `TrueClass` and `FalseClass`, but no
    # `Boolean` class), so we set the primitive to nil to prevent
    # odd stuff from happening.  It can still be matched by other
    # values.
    class Boolean < Object
      options[:primitive] = nil
      as :bool, :boolean, true, false

      constraints.clear
      constraint do |value|
        [TrueClass, FalseClass].include?(value.class)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mixture-0.4.0 lib/mixture/types/boolean.rb
mixture-0.3.6 lib/mixture/types/boolean.rb
mixture-0.3.5 lib/mixture/types/boolean.rb
mixture-0.3.4 lib/mixture/types/boolean.rb
mixture-0.3.2 lib/mixture/types/boolean.rb
mixture-0.3.1 lib/mixture/types/boolean.rb
mixture-0.3.0 lib/mixture/types/boolean.rb