Class: PackageProtections::ViolationBehavior
- Inherits:
-
T::Enum
- Object
- T::Enum
- PackageProtections::ViolationBehavior
- Extended by:
- T::Sig
- Defined in:
- lib/package_protections/violation_behavior.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_raw_value(value) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/package_protections/violation_behavior.rb', line 18 def self.from_raw_value(value) ViolationBehavior.deserialize(value.to_s) rescue KeyError # Let's not encourage "unknown." That's mostly considered an internal value if nothing is specified. acceptable_values = ViolationBehavior.values.map(&:serialize) - ['unknown'] raise IncorrectPublicApiUsageError.new("The metadata value #{value} is not a valid behavior. Double check your spelling! Acceptable values are #{acceptable_values}. See https://github.com/rubyatscale/package_protections#readme for more info") # rubocop:disable Style/RaiseArgs end |
Instance Method Details
#enabled? ⇒ Boolean
38 39 40 41 42 43 44 45 46 |
# File 'lib/package_protections/violation_behavior.rb', line 38 def enabled? case self when FailOnAny then true when FailOnNew then true when FailNever then false else T.absurd(self) end end |
#fail_never? ⇒ Boolean
60 61 62 63 64 65 66 67 68 |
# File 'lib/package_protections/violation_behavior.rb', line 60 def fail_never? case self when FailOnAny then false when FailOnNew then false when FailNever then true else T.absurd(self) end end |
#fail_on_any? ⇒ Boolean
27 28 29 30 31 32 33 34 35 |
# File 'lib/package_protections/violation_behavior.rb', line 27 def fail_on_any? case self when FailOnAny then true when FailOnNew then false when FailNever then false else T.absurd(self) end end |
#fail_on_new? ⇒ Boolean
49 50 51 52 53 54 55 56 57 |
# File 'lib/package_protections/violation_behavior.rb', line 49 def fail_on_new? case self when FailOnAny then false when FailOnNew then true when FailNever then false else T.absurd(self) end end |