Class: Eventually::Validation::Arity
- Inherits:
-
Object
- Object
- Eventually::Validation::Arity
- Defined in:
- lib/eventually/validation/arity.rb
Instance Attribute Summary collapse
-
#expected ⇒ Object
readonly
Returns the value of attribute expected.
-
#received ⇒ Object
readonly
Returns the value of attribute received.
Instance Method Summary collapse
-
#initialize(event, emitter, arity) ⇒ Arity
constructor
A new instance of Arity.
- #raise_unless_valid! ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(event, emitter, arity) ⇒ Arity
Returns a new instance of Arity.
6 7 8 9 10 11 |
# File 'lib/eventually/validation/arity.rb', line 6 def initialize(event, emitter, arity) @event = event @emitter = emitter @arity = @received = arity @expected = @emitter.class.arity_for_event(@event) end |
Instance Attribute Details
#expected ⇒ Object (readonly)
Returns the value of attribute expected.
5 6 7 |
# File 'lib/eventually/validation/arity.rb', line 5 def expected @expected end |
#received ⇒ Object (readonly)
Returns the value of attribute received.
5 6 7 |
# File 'lib/eventually/validation/arity.rb', line 5 def received @received end |
Instance Method Details
#raise_unless_valid! ⇒ Object
17 18 19 |
# File 'lib/eventually/validation/arity.rb', line 17 def raise_unless_valid! raise "Arity validation failed for event :#{@event} (expected #{@expected}, received #{@received})" unless valid? end |
#valid? ⇒ Boolean
13 14 15 |
# File 'lib/eventually/validation/arity.rb', line 13 def valid? !@emitter.class.validates_arity?(@event) || @received == @expected end |