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 def initialize: ( type: Symbol, value: untyped, ?subject: untyped, ?expectations: BCDD::Result::Contract::Evaluator ) -> void def type: -> Symbol def value: -> untyped 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 name: -> 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 name: -> 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 name: -> 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 Methods def Success: (Symbol type, ?untyped value) -> BCDD::Result::Success def Failure: (Symbol type, ?untyped value) -> BCDD::Result::Failure 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: (Array[Symbol]) -> Array[Module] end def self.module!: -> Module end def self.mixin: (?with: Array[Symbol]) -> Module end class BCDD::Result class Data attr_reader name: 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]) -> BCDD::Result::Contract::Evaluator def self.new: ( success: Hash[Symbol, untyped] | Array[Symbol], failure: Hash[Symbol, untyped] | Array[Symbol] ) -> BCDD::Result::Contract::Evaluator def self.nil_as_valid_value_checking!: (?enabled: bool) -> void def self.nil_as_valid_value_checking?: -> bool 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]) -> void 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: ( ?with: Symbol, ?success: Hash[Symbol, untyped] | Array[Symbol], ?failure: Hash[Symbol, untyped] | Array[Symbol] ) -> Module def initialize: ( ?subject: untyped, ?success: Hash[Symbol, untyped] | Array[Symbol], ?failure: Hash[Symbol, untyped] | Array[Symbol], ?contract: BCDD::Result::Contract::Evaluator ) -> void def Success: (Symbol, ?untyped) -> BCDD::Result::Success def Failure: (Symbol, ?untyped) -> BCDD::Result::Failure def with: (subject: untyped) -> BCDD::Result::Expectations private attr_reader subject: untyped attr_reader contract: BCDD::Result::Contract::Evaluator end module BCDD::Result::Expectations::Mixin METHODS: String module Addons module Continuable private def Continue: (untyped) -> BCDD::Result::Success end OPTIONS: Hash[Symbol, Module] def self.options: (Symbol) -> Array[Module] end def self.module!: -> Module 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 ) -> 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 module Methods def Success: (Symbol, **untyped) -> BCDD::Result::Context::Success def Failure: (Symbol, **untyped) -> BCDD::Result::Context::Failure 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: (Array[Symbol]) -> Array[Module] end end def self.mixin: (?with: Array[Symbol]) -> Module end class BCDD::Result::Context::Expectations def self.mixin: ( ?with: Symbol, ?success: Hash[Symbol, untyped] | Array[Symbol], ?failure: Hash[Symbol, untyped] | Array[Symbol] ) -> Module def initialize: ( ?subject: untyped, ?success: Hash[Symbol, untyped] | Array[Symbol], ?failure: Hash[Symbol, untyped] | Array[Symbol], ?contract: BCDD::Result::Contract::Evaluator ) -> void def Success: (Symbol, **untyped) -> BCDD::Result::Context::Success def Failure: (Symbol, **untyped) -> BCDD::Result::Context::Failure def with: (subject: untyped) -> BCDD::Result::Context::Expectations private attr_reader subject: untyped attr_reader contract: BCDD::Result::Contract::Evaluator end module BCDD::Result::Context::Expectations::Mixin METHODS: String module Addons module Continuable private def Continue: (**untyped) -> BCDD::Result::Context::Success end OPTIONS: Hash[Symbol, Module] def self.options: (Symbol) -> Array[Module] end end