Sha256: f0ae95ac146093a2ad346a3695cc7d1e3060c6fd6b9da0937d1bf7e6d643de5b

Contents?: true

Size: 1.99 KB

Versions: 11

Compression:

Stored size: 1.99 KB

Contents

# encoding: utf-8

require 'bigdecimal'
require 'date'
require 'set'
require 'singleton'

require 'descendants_tracker'
require 'ice_nine'
require 'thread_safe'

module Axiom

  # Gem namespace
  module Types

    # Represent an undefined argument
    Undefined = Object.new.freeze

    # A true proposition
    Tautology = ->(_value) { true }.freeze

    # A false proposition
    Contradiction = ->(_value) { true }.freeze

    # Cache the type inference lookup by object
    @inference_cache = ThreadSafe::Cache.new do |cache, object|
      type = nil
      Type.descendants.detect do |descendant|
        type = descendant.infer(object)
      end
      cache[object] = type
    end

    # Infer the type of an object
    #
    # @example
    #   Axiom::Types.infer(Integer)  # => Axiom::Types::Integer
    #
    # @param [Object] object
    #   object to infer the type of
    #
    # @return [Class<Axiom::Types::Type>]
    #
    # @api public
    def self.infer(object)
      @inference_cache[object]
    end

    # Finalize Axiom::Types::Type subclasses
    #
    # @example
    #   Axiom::Types.finalize  # => Axiom::Types
    #
    # @return [Module<Axiom::Types>]
    #
    # @api public
    def self.finalize
      Type.descendants.each(&:finalize)
      self
    end

  end # module Types
end # module Axiom

require 'axiom/types/support/options'
require 'axiom/types/support/infinity'

require 'axiom/types/value_comparable'
require 'axiom/types/length_comparable'
require 'axiom/types/encodable'

require 'axiom/types/type'

require 'axiom/types/object'

require 'axiom/types/collection'
require 'axiom/types/numeric'

require 'axiom/types/array'
require 'axiom/types/boolean'
require 'axiom/types/class'
require 'axiom/types/date'
require 'axiom/types/date_time'
require 'axiom/types/decimal'
require 'axiom/types/float'
require 'axiom/types/hash'
require 'axiom/types/integer'
require 'axiom/types/set'
require 'axiom/types/string'
require 'axiom/types/symbol'
require 'axiom/types/time'

require 'axiom/types/version'

Version data entries

11 entries across 9 versions & 4 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/axiom-types-0.1.1/lib/axiom/types.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/axiom-types-0.1.1/lib/axiom/types.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/axiom-types-0.1.1/lib/axiom/types.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/axiom-types-0.1.1/lib/axiom/types.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/axiom-types-0.1.1/lib/axiom/types.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/axiom-types-0.1.1/lib/axiom/types.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/axiom-types-0.1.1/lib/axiom/types.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/axiom-types-0.1.1/lib/axiom/types.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/axiom-types-0.1.1/lib/axiom/types.rb
axiom-types-0.1.1 lib/axiom/types.rb
axiom-types-0.1.0 lib/axiom/types.rb