Class: Solid::Result::Handler::AllowedTypes
- Inherits:
-
Object
- Object
- Solid::Result::Handler::AllowedTypes
- Defined in:
- lib/solid/result/handler/allowed_types.rb
Instance Attribute Summary collapse
-
#type_checker ⇒ Object
readonly
Returns the value of attribute type_checker.
-
#unchecked ⇒ Object
readonly
Returns the value of attribute unchecked.
Instance Method Summary collapse
- #all_checked? ⇒ Boolean
- #allow?(types) ⇒ Boolean
- #allow_failure?(types) ⇒ Boolean
- #allow_success?(types) ⇒ Boolean
-
#initialize(type_checker) ⇒ AllowedTypes
constructor
A new instance of AllowedTypes.
Constructor Details
#initialize(type_checker) ⇒ AllowedTypes
Returns a new instance of AllowedTypes.
8 9 10 11 12 13 14 |
# File 'lib/solid/result/handler/allowed_types.rb', line 8 def initialize(type_checker) @type_checker = type_checker @expectations = type_checker.expectations @unchecked = @expectations.allowed_types.dup end |
Instance Attribute Details
#type_checker ⇒ Object (readonly)
Returns the value of attribute type_checker.
6 7 8 |
# File 'lib/solid/result/handler/allowed_types.rb', line 6 def type_checker @type_checker end |
#unchecked ⇒ Object (readonly)
Returns the value of attribute unchecked.
6 7 8 |
# File 'lib/solid/result/handler/allowed_types.rb', line 6 def unchecked @unchecked end |
Instance Method Details
#all_checked? ⇒ Boolean
32 33 34 |
# File 'lib/solid/result/handler/allowed_types.rb', line 32 def all_checked? unchecked.empty? end |
#allow?(types) ⇒ Boolean
16 17 18 |
# File 'lib/solid/result/handler/allowed_types.rb', line 16 def allow?(types) check!(types, type_checker.allow?(types)) end |
#allow_failure?(types) ⇒ Boolean
26 27 28 29 30 |
# File 'lib/solid/result/handler/allowed_types.rb', line 26 def allow_failure?(types) unchecked.subtract(@expectations.failure.allowed_types) if types.empty? check!(types, type_checker.allow_failure?(types)) end |
#allow_success?(types) ⇒ Boolean
20 21 22 23 24 |
# File 'lib/solid/result/handler/allowed_types.rb', line 20 def allow_success?(types) unchecked.subtract(@expectations.success.allowed_types) if types.empty? check!(types, type_checker.allow_success?(types)) end |