class Protocol::Postcondition

This class is a proxy that stores postcondition blocks, which are called after the result of the wrapped method was determined.

Public Class Methods

new(object) click to toggle source
# File lib/protocol/post_condition.rb, line 9
def initialize(object)
  @object = object
  @blocks = []
end

Public Instance Methods

__result__() click to toggle source

This is the alternative result “keyword”.

# File lib/protocol/post_condition.rb, line 15
def __result__
  @result
end
method_missing(*a, &b) click to toggle source

Send all remaining messages to the object.

# File lib/protocol/post_condition.rb, line 53
def method_missing(*a, &b)
  @object.__send__(*a, &b)
end
myself() click to toggle source

This is the “keyword” to be used instead of self to refer to current object.

# File lib/protocol/post_condition.rb, line 33
def myself
  @object
end
result() click to toggle source

This is the result “keyword” which can be used to query the result of wrapped method in a postcondition clause.

# File lib/protocol/post_condition.rb, line 21
def result
  if @object.respond_to? :result
    warn "#{@object.class} already defines a result method, "\
      "try __result__ instead"
    @object.__send__(:result)
  else
    @result
  end
end