Class: Messaging::ExpectedVersion
- Inherits:
-
Object
- Object
- Messaging::ExpectedVersion
- Defined in:
- lib/messaging/expected_version.rb
Constant Summary collapse
- Error =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #any? ⇒ Boolean
-
#initialize(version) ⇒ ExpectedVersion
constructor
A new instance of ExpectedVersion.
- #match!(other_version) ⇒ Object
- #matches?(other_version) ⇒ Boolean
- #none? ⇒ Boolean
Constructor Details
#initialize(version) ⇒ ExpectedVersion
Returns a new instance of ExpectedVersion.
7 8 9 |
# File 'lib/messaging/expected_version.rb', line 7 def initialize(version) @version = version end |
Instance Attribute Details
#version ⇒ Object (readonly)
Returns the value of attribute version.
5 6 7 |
# File 'lib/messaging/expected_version.rb', line 5 def version @version end |
Instance Method Details
#any? ⇒ Boolean
11 12 13 |
# File 'lib/messaging/expected_version.rb', line 11 def any? version == :any end |
#match!(other_version) ⇒ Object
26 27 28 29 |
# File 'lib/messaging/expected_version.rb', line 26 def match!(other_version) return true if matches?(other_version) raise Error, "expected: #{version} actual: #{other_version}" end |
#matches?(other_version) ⇒ Boolean
19 20 21 22 23 24 |
# File 'lib/messaging/expected_version.rb', line 19 def matches?(other_version) return true if any? return true if none? && other_version == -1 return true if version == other_version false end |
#none? ⇒ Boolean
15 16 17 |
# File 'lib/messaging/expected_version.rb', line 15 def none? version == :none || version == -1 end |