Class: Contracts::Precondition
- Defined in:
- lib/ruby_contracts/precondition.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
- #after? ⇒ Boolean
- #before? ⇒ Boolean
-
#initialize(message, block) ⇒ Precondition
constructor
A new instance of Precondition.
- #satisfied?(context, arguments, result = nil) ⇒ Boolean
Constructor Details
#initialize(message, block) ⇒ Precondition
Returns a new instance of Precondition.
5 6 7 8 |
# File 'lib/ruby_contracts/precondition.rb', line 5 def initialize(, block) @message = "invalid precondition: #{ || 'no message given'}" @block = block end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
3 4 5 |
# File 'lib/ruby_contracts/precondition.rb', line 3 def @message end |
Instance Method Details
#after? ⇒ Boolean
18 19 20 |
# File 'lib/ruby_contracts/precondition.rb', line 18 def after? false end |
#before? ⇒ Boolean
14 15 16 |
# File 'lib/ruby_contracts/precondition.rb', line 14 def before? true end |
#satisfied?(context, arguments, result = nil) ⇒ Boolean
10 11 12 |
# File 'lib/ruby_contracts/precondition.rb', line 10 def satisfied?(context, arguments, result=nil) context.instance_exec(*arguments, &@block) end |