Class: Contracts::Returns

Inherits:
Base
  • Object
show all
Defined in:
lib/contracts/returns.rb

Overview

Author

radiospiel ([email protected])

Copyright

Copyright © 2011, 2012 radiospiel

License

Distributes under the terms of the Modified BSD License, see LICENSE.BSD for details.

++

Instance Attribute Summary collapse

Attributes inherited from Base

#method

Instance Method Summary collapse

Methods inherited from Base

#+@, #method_name

Constructor Details

#initialize(expectation) ⇒ Returns

Returns a new instance of Returns.



11
12
13
# File 'lib/contracts/returns.rb', line 11

def initialize(expectation)
  @expectation = expectation
end

Instance Attribute Details

#expectationObject (readonly)

Returns the value of attribute expectation.



9
10
11
# File 'lib/contracts/returns.rb', line 9

def expectation
  @expectation
end

Instance Method Details

#after_call(_, rv, _receiver, *_args, &_blk) ⇒ Object



15
16
17
18
19
# File 'lib/contracts/returns.rb', line 15

def after_call(_, rv, _receiver, *_args, &_blk)
  Expectation::Matcher.match! rv, expectation
rescue Expectation::Error
  error! "#{$ERROR_INFO} in return of `#{method_name}`"
end