Created
June 20, 2013 15:52
-
-
Save cored/5824010 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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