Skip to content

Instantly share code, notes, and snippets.

@cored
Created June 20, 2013 15:52
Show Gist options
  • Save cored/5824010 to your computer and use it in GitHub Desktop.
Save cored/5824010 to your computer and use it in GitHub Desktop.
# encoding: utf-8
module Axiom
class Attribute
# Represents a Boolean value in a relation tuple
class Boolean < Object
include Function::Connective::Conjunction::Methods,
Function::Connective::Disjunction::Methods,
Function::Connective::Negation::Methods
# The Boolean primitive
#
# @example
# Boolean.primitive # => TrueClass
#
# @return [Class<TrueClass>]
#
# @api public
def self.primitive
::Axiom::Types.infer(::Axiom::Types::TrueClass)
end
# Test if the value is a boolean
#
# @example
# boolean.valid_value?(value) # => true or false
#
# @param [Object] value
# the value to test
#
# @return [Boolean]
#
# @api public
def valid_value?(value)
valid_or_optional?(value) { super || value.kind_of?(::FalseClass) }
end
end # class Boolean
# Add aliases for Boolean
TrueClass = Boolean
FalseClass = Boolean
end # class Attribute
end # module Axiom
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment