Module: Dry::Monads::RSpec Private

Defined in:
lib/dry/monads/extensions/rspec.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Modules: Matchers

Constant Summary collapse

Constructors =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

CONSTANTS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

%i[Success Failure Some None List].to_set
NESTED_CONSTANTS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

CONSTANTS.to_set { |c| "::#{c}" }

Class Method Summary collapse

Class Method Details

.name_to_const(name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/dry/monads/extensions/rspec.rb', line 148

def name_to_const(name)
  case name
  in :Success
    ::Dry::Monads::Result::Success
  in :Failure
    ::Dry::Monads::Result::Failure
  in :Some
    ::Dry::Monads::Maybe::Some
  in :None
    ::Dry::Monads::Maybe::None
  in :List
    ::Dry::Monads::List
  end
end

.resolve_constant_name(name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



138
139
140
141
142
143
144
145
146
# File 'lib/dry/monads/extensions/rspec.rb', line 138

def resolve_constant_name(name)
  if CONSTANTS.include?(name)
    name
  elsif NESTED_CONSTANTS.any? { |c| name.to_s.end_with?(c) }
    name[/::(\w+)$/, 1].to_sym
  else
    nil
  end
end