module BCDD class Result VERSION: String end end class BCDD::Result private attr_accessor unknown: bool private attr_reader type_checker: BCDD::Result::Contract::TypeChecker attr_reader data: BCDD::Result::Data attr_reader subject: untyped attr_reader halted: bool def self.config: -> BCDD::Result::Config def self.configuration: { (BCDD::Result::Config) -> void } -> BCDD::Result::Config def initialize: ( type: Symbol, value: untyped, ?subject: untyped, ?expectations: BCDD::Result::Contract::Evaluator, ?halted: bool ) -> void def type: -> Symbol def value: -> untyped def halted?: -> bool def success?: (?Symbol type) -> bool def failure?: (?Symbol type) -> bool def value_or: { () -> untyped } -> untyped def on: (*Symbol) { (untyped, Symbol) -> void } -> BCDD::Result def on_success: (*Symbol) { (untyped, Symbol) -> void } -> BCDD::Result def on_failure: (*Symbol) { (untyped, Symbol) -> void } -> BCDD::Result def on_unknown: () { (untyped, Symbol) -> void } -> BCDD::Result def and_then: (?Symbol method_name, ?untyped context) ?{ (untyped) -> untyped } -> untyped def handle: () { (BCDD::Result::Handler) -> void } -> untyped def ==: (untyped) -> bool def hash: -> Integer def inspect: -> String def deconstruct: -> [Symbol, [Symbol, untyped]] def deconstruct_keys: (Array[Symbol]) -> Hash[Symbol, Hash[Symbol, untyped]] alias eql? == alias on_type on private def kind: -> Symbol def known: (Proc) -> untyped def call_subject_method: (Symbol, untyped) -> BCDD::Result def ensure_result_object: (untyped, origin: Symbol) -> BCDD::Result end class BCDD::Result class Success < BCDD::Result module Methods def success?: (?Symbol type) -> bool def failure?: (?Symbol type) -> bool def value_or: { () -> untyped } -> untyped def value: -> untyped private def kind: -> Symbol def type_checker: -> BCDD::Result::Contract::TypeChecker end include Methods end def self.Failure: (Symbol type, ?untyped value) -> BCDD::Result::Failure end class BCDD::Result class Failure < BCDD::Result module Methods def success?: (?Symbol type) -> bool def failure?: (?Symbol type) -> bool def value_or: { (untyped) -> untyped } -> untyped def value: -> untyped private def kind: -> Symbol def type_checker: -> BCDD::Result::Contract::TypeChecker end include Methods end def self.Success: (Symbol type, ?untyped value) -> BCDD::Result::Success end class BCDD::Result module Mixin module Factory def self.module!: -> Module end module Methods def Success: (Symbol type, ?untyped value) -> BCDD::Result::Success def Failure: (Symbol type, ?untyped value) -> BCDD::Result::Failure private def _ResultAs: (singleton(BCDD::Result), Symbol, untyped, ?halted: bool) -> untyped end module Addons module Continuable include BCDD::Result::Mixin::Methods private def Continue: (untyped) -> BCDD::Result::Success end OPTIONS: Hash[Symbol, Module] def self.options: (Hash[Symbol, Hash[Symbol, bool]]) -> Hash[Symbol, Module] end end def self.mixin: (?config: Hash[Symbol, Hash[Symbol, bool]]) -> Module def self.mixin_module: -> singleton(BCDD::Result::Mixin) def self.result_factory: -> singleton(BCDD::Result) end class BCDD::Result class Data attr_reader kind: Symbol attr_reader type: Symbol attr_reader value: untyped attr_reader to_h: Hash[Symbol, untyped] attr_reader to_a: [Symbol, Symbol, untyped] def initialize: (Symbol, Symbol, untyped) -> void def inspect: -> String alias to_ary to_a alias to_hash to_h end end class BCDD::Result class Error < StandardError def self.build: (**untyped) -> BCDD::Result::Error class NotImplemented < BCDD::Result::Error end class MissingTypeArgument < BCDD::Result::Error end class UnexpectedOutcome < BCDD::Result::Error def self.build: (outcome: untyped, origin: Symbol, ?expected: String) -> BCDD::Result::Error::UnexpectedOutcome end class InvalidResultSubject < BCDD::Result::Error def self.build: (given_result: BCDD::Result, expected_subject: untyped) -> BCDD::Result::Error::InvalidResultSubject end class InvalidSubjectMethodArity < BCDD::Result::Error def self.build: (subject: untyped, method: Method, max_arity: Integer) -> BCDD::Result::Error::InvalidSubjectMethodArity end class UnhandledTypes < BCDD::Result::Error def self.build: (types: Set[Symbol]) -> BCDD::Result::Error::UnhandledTypes end end end class BCDD::Result class Handler UNDEFINED: Object def initialize: ( BCDD::Result, type_checker: BCDD::Result::Contract::TypeChecker ) -> void def []: (*Symbol) { (untyped, Symbol) -> void } -> untyped def failure: (*Symbol) { (untyped, Symbol) -> void } -> untyped def success: (*Symbol) { (untyped, Symbol) -> void } -> untyped def unknown: () { (untyped, Symbol) -> void } -> untyped alias type [] private attr_reader result: BCDD::Result attr_reader allowed_types: BCDD::Result::Handler::AllowedTypes def outcome?: -> bool def outcome=: (Proc) -> void def outcome: -> untyped end end class BCDD::Result::Handler class AllowedTypes attr_reader unchecked: Set[Symbol] attr_reader type_checker: BCDD::Result::Contract::TypeChecker def initialize: ( BCDD::Result::Contract::TypeChecker ) -> void def allow?: (Array[Symbol]) -> bool def allow_success?: (Array[Symbol]) -> bool def allow_failure?: (Array[Symbol]) -> bool def all_checked?: -> bool private def check!: (Array[Symbol], bool) -> bool end end module BCDD::Result::Contract NONE: BCDD::Result::Contract::Evaluator def self.evaluate: ( BCDD::Result::Data, BCDD::Result::Contract::Evaluator ) -> BCDD::Result::Contract::TypeChecker ToEnsure: ^(Hash[Symbol, untyped] | Array[Symbol], Hash[Symbol, Hash[Symbol, bool]]) -> BCDD::Result::Contract::Interface def self.new: ( success: Hash[Symbol, untyped] | Array[Symbol], failure: Hash[Symbol, untyped] | Array[Symbol], config: Hash[Symbol, Hash[Symbol, bool]] ) -> BCDD::Result::Contract::Evaluator end module BCDD::Result::Contract class TypeChecker attr_reader result_type: Symbol attr_reader expectations: BCDD::Result::Contract::Evaluator def initialize: ( Symbol, expectations: BCDD::Result::Contract::Evaluator ) -> void def allow?: (Array[Symbol]) -> bool def allow_success?: (Array[Symbol]) -> bool def allow_failure?: (Array[Symbol]) -> bool private def validate: ( Array[Symbol], expected: BCDD::Result::Contract::Interface, allow_empty: bool ) -> bool end end class BCDD::Result::Contract::Error < BCDD::Result::Error class UnexpectedType < BCDD::Result::Contract::Error def self.build: (type: Symbol, allowed_types: Set[Symbol]) -> BCDD::Result::Contract::Error::UnexpectedType end class UnexpectedValue < BCDD::Result::Contract::Error def self.build: (type: Symbol, value: untyped, ?cause: Exception) -> BCDD::Result::Contract::Error::UnexpectedValue end end module BCDD::Result::Contract module Interface def ==: (BCDD::Result::Contract::Interface) -> bool def allowed_types: -> Set[Symbol] def type?: (Symbol) -> bool def type!: (Symbol) -> Symbol def type_and_value!: (BCDD::Result::Data) -> void def !=: (untyped) -> bool end end module BCDD::Result::Contract module Disabled extend Interface EMPTY_SET: Set[Symbol] end end module BCDD::Result::Contract class ForTypes include Interface def initialize: (Array[Symbol]) -> void end end module BCDD::Result::Contract class ForTypesAndValues include Interface def initialize: ( Hash[Symbol, untyped], Hash[Symbol, Hash[Symbol, bool]] ) -> void private def nil_as_valid_value_checking?: -> bool end end module BCDD::Result::Contract class Evaluator include Interface attr_reader allowed_types: Set[Symbol] attr_reader success: BCDD::Result::Contract::Interface attr_reader failure: BCDD::Result::Contract::Interface def initialize: ( BCDD::Result::Contract::Interface, BCDD::Result::Contract::Interface ) -> void private def for: (BCDD::Result::Data) -> BCDD::Result::Contract::Interface end end class BCDD::Result::Expectations def self.mixin: ( ?config: Hash[Symbol, Hash[Symbol, bool]], ?success: Hash[Symbol, untyped] | Array[Symbol], ?failure: Hash[Symbol, untyped] | Array[Symbol] ) -> Module def self.mixin!: ( ?config: Hash[Symbol, Hash[Symbol, bool]], ?success: Hash[Symbol, untyped] | Array[Symbol], ?failure: Hash[Symbol, untyped] | Array[Symbol] ) -> Module def self.mixin_module: -> singleton(BCDD::Result::Expectations::Mixin) def self.result_factory_without_expectations: -> singleton(BCDD::Result) def self.new: ( ?subject: untyped, ?contract: BCDD::Result::Contract::Evaluator, ?halted: bool, **untyped ) -> (BCDD::Result::Expectations | untyped) def initialize: ( ?subject: untyped, ?contract: BCDD::Result::Contract::Evaluator, ?halted: bool, **untyped ) -> void def Success: (Symbol, ?untyped) -> BCDD::Result::Success def Failure: (Symbol, ?untyped) -> BCDD::Result::Failure def with: (subject: untyped) -> BCDD::Result::Expectations private def _ResultAs: (singleton(BCDD::Result), Symbol, untyped) -> untyped attr_reader subject: untyped attr_reader contract: BCDD::Result::Contract::Evaluator attr_reader halted: bool end module BCDD::Result::Expectations::Mixin module Factory def self.module!: -> Module end module Methods BASE: String FACTORY: String def self.to_eval: (Hash[Symbol, untyped]) -> String end module Addons module Continuable private def Continue: (untyped) -> BCDD::Result::Success end OPTIONS: Hash[Symbol, Module] def self.options: (Hash[Symbol, Hash[Symbol, bool]]) -> Hash[Symbol, Module] end end class BCDD::Result::Context < BCDD::Result EXPECTED_OUTCOME: String SubjectMethodArity: ^(Method) -> Integer attr_reader acc: Hash[Symbol, untyped] def initialize: ( type: Symbol, value: untyped, ?subject: untyped, ?expectations: BCDD::Result::Contract::Evaluator, ?halted: bool ) -> void def and_then: (?Symbol, **untyped) ?{ (Hash[Symbol, untyped]) -> untyped } -> BCDD::Result::Context private def call_subject_method: (Symbol, Hash[Symbol, untyped]) -> BCDD::Result::Context def ensure_result_object: (untyped, origin: Symbol) -> BCDD::Result::Context def raise_unexpected_outcome_error: (BCDD::Result::Context | untyped, Symbol) -> void end class BCDD::Result::Context class Success < BCDD::Result::Context include BCDD::Result::Success::Methods def and_expose: (Symbol, Array[Symbol]) -> BCDD::Result::Context::Success end def self.Success: (Symbol, **untyped) -> BCDD::Result::Context::Success end class BCDD::Result::Context class Failure < BCDD::Result::Context include BCDD::Result::Failure::Methods def and_expose: (Symbol, Array[Symbol]) -> BCDD::Result::Context::Failure end def self.Failure: (Symbol, **untyped) -> BCDD::Result::Context::Failure end class BCDD::Result::Context module Mixin Factory: singleton(BCDD::Result::Mixin::Factory) module Methods def Success: (Symbol, **untyped) -> BCDD::Result::Context::Success def Failure: (Symbol, **untyped) -> BCDD::Result::Context::Failure private def _ResultAs: (singleton(BCDD::Result::Context), Symbol, untyped, ?halted: bool) -> untyped end module Addons module Continuable include BCDD::Result::Context::Mixin::Methods private def Continue: (**untyped) -> BCDD::Result::Context::Success end OPTIONS: Hash[Symbol, Module] def self.options: (Hash[Symbol, Hash[Symbol, bool]]) -> Hash[Symbol, Module] end end def self.mixin_module: -> singleton(BCDD::Result::Context::Mixin) def self.result_factory: -> singleton(BCDD::Result::Context) end class BCDD::Result::Context::Expectations < BCDD::Result::Expectations def self.mixin_module: -> singleton(BCDD::Result::Context::Expectations::Mixin) def self.result_factory_without_expectations: -> singleton(BCDD::Result) def Success: (Symbol, **untyped) -> BCDD::Result::Context::Success def Failure: (Symbol, **untyped) -> BCDD::Result::Context::Failure end module BCDD::Result::Context::Expectations::Mixin Methods: singleton(BCDD::Result::Expectations::Mixin::Methods) Factory: singleton(BCDD::Result::Expectations::Mixin::Factory) module Addons module Continuable private def Continue: (**untyped) -> BCDD::Result::Context::Success end OPTIONS: Hash[Symbol, Module] def self.options: (Hash[Symbol, Hash[Symbol, bool]]) -> Hash[Symbol, Module] end end class BCDD::Result::Config include Singleton ADDON: Hash[Symbol, Hash[Symbol, untyped]] FEATURE: Hash[Symbol, Hash[Symbol, untyped]] PATTERN_MATCHING: Hash[Symbol, Hash[Symbol, untyped]] attr_reader addon: BCDD::Result::Config::Switcher attr_reader feature: BCDD::Result::Config::Switcher attr_reader constant_alias: BCDD::Result::Config::Switcher attr_reader pattern_matching: BCDD::Result::Config::Switcher def self.instance: -> BCDD::Result::Config def initialize: -> void def freeze: -> BCDD::Result::Config def options: -> Hash[Symbol, BCDD::Result::Config::Switcher] def to_h: -> Hash[Symbol, Hash[Symbol | String, bool]] end class BCDD::Result::Config::Switcher private attr_reader _affects: Hash[Symbol | String, Array[String]] private attr_reader _options: Hash[Symbol | String, bool] private attr_reader listener: Proc def initialize: ( options: Hash[Symbol | String, Hash[Symbol, untyped]], ?listener: Proc ) -> void def freeze: -> BCDD::Result::Config::Switcher def to_h: -> Hash[Symbol | String, bool] def options: -> Hash[Symbol | String, Hash[Symbol, untyped]] def enabled?: (Symbol | String) -> bool def enable!: (*(Symbol | String)) -> Hash[Symbol | String, Hash[Symbol, untyped]] def disable!: (*(Symbol | String)) -> Hash[Symbol | String, Hash[Symbol, untyped]] private def set_many: (Array[Symbol | String], to: bool) -> Hash[Symbol | String, Hash[Symbol, untyped]] def set_one: (Symbol | String, bool) -> void def require_option!: (Array[Symbol | String]) -> void def validate_option!: (Symbol | String) -> void def available_options_message: -> String end module BCDD::Result::Config::ConstantAlias MAPPING: Hash[String, Hash[Symbol, untyped]] OPTIONS: Hash[String, Hash[Symbol, untyped]] Listener: Proc def self.switcher: -> BCDD::Result::Config::Switcher end module BCDD::Result::Config::Options def self.with_defaults: ( Hash[Symbol, Hash[Symbol, bool]], Symbol ) -> Hash[Symbol, bool] def self.select: ( Hash[Symbol, Hash[Symbol, bool]], config: Symbol, from: Hash[Symbol, untyped] ) -> Hash[Symbol, untyped] def self.addon: ( map: Hash[Symbol, Hash[Symbol, bool]], from: Hash[Symbol, Module] ) -> Hash[Symbol, Module] end