Class: ActiveDoc::Descriptions::MethodArgumentDescription::DuckArgumentExpectation
- Inherits:
-
ArgumentExpectation
- Object
- ArgumentExpectation
- ActiveDoc::Descriptions::MethodArgumentDescription::DuckArgumentExpectation
- Defined in:
- lib/active_doc/descriptions/method_argument_description.rb
Class Method Summary collapse
Instance Method Summary collapse
- #condition?(value, args_with_vals) ⇒ Boolean
-
#expectation_fail_to_s ⇒ Object
Expected to…
-
#initialize(argument) ⇒ DuckArgumentExpectation
constructor
A new instance of DuckArgumentExpectation.
- #to_rdoc ⇒ Object
Methods inherited from ArgumentExpectation
#additional_rdoc, find, #fulfilled?, inherited
Constructor Details
#initialize(argument) ⇒ DuckArgumentExpectation
Returns a new instance of DuckArgumentExpectation.
289 290 291 292 |
# File 'lib/active_doc/descriptions/method_argument_description.rb', line 289 def initialize(argument) @respond_to = argument @respond_to = [@respond_to] unless @respond_to.is_a? Array end |
Class Method Details
.from(argument, options, proc) ⇒ Object
311 312 313 314 315 |
# File 'lib/active_doc/descriptions/method_argument_description.rb', line 311 def self.from(argument, , proc) if [:duck] self.new([:duck]) end end |
Instance Method Details
#condition?(value, args_with_vals) ⇒ Boolean
294 295 296 297 |
# File 'lib/active_doc/descriptions/method_argument_description.rb', line 294 def condition?(value, args_with_vals) @failed_quacks = @respond_to.find_all {|quack| not value.respond_to? quack} @failed_quacks.empty? end |
#expectation_fail_to_s ⇒ Object
Expected to… NOTE: Possible thread-safe problem
301 302 303 |
# File 'lib/active_doc/descriptions/method_argument_description.rb', line 301 def expectation_fail_to_s "be respond to #{@respond_to.inspect}, missing #{@failed_quacks.inspect}" end |
#to_rdoc ⇒ Object
305 306 307 308 309 |
# File 'lib/active_doc/descriptions/method_argument_description.rb', line 305 def to_rdoc respond_to = @respond_to respond_to = respond_to.first if respond_to.size == 1 "respond to #{respond_to.inspect}" end |