Class: ActiveDoc::Descriptions::MethodArgumentDescription::ComplexConditionArgumentExpectation

Inherits:
ArgumentExpectation
  • Object
show all
Defined in:
lib/active_doc/descriptions/method_argument_description.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ArgumentExpectation

#additional_rdoc, find, #fulfilled?, inherited

Constructor Details

#initialize(argument) ⇒ ComplexConditionArgumentExpectation

Returns a new instance of ComplexConditionArgumentExpectation.



208
209
210
# File 'lib/active_doc/descriptions/method_argument_description.rb', line 208

def initialize(argument)
  @proc = argument
end

Class Method Details

.from(argument, options, proc) ⇒ Object



226
227
228
229
230
# File 'lib/active_doc/descriptions/method_argument_description.rb', line 226

def self.from(argument, options, proc)
  if proc.is_a?(Proc) && proc.arity == 1
    self.new(proc)
  end
end

Instance Method Details

#condition?(value, args_with_vals) ⇒ Boolean

Returns:

  • (Boolean)


212
213
214
215
# File 'lib/active_doc/descriptions/method_argument_description.rb', line 212

def condition?(value, args_with_vals)
  other_values = args_with_vals.inject({}) { |h, (k, v)| h[k] = v[:val];h }
  @proc.call(other_values)
end

#expectation_fail_to_sObject

Expected to…



218
219
220
# File 'lib/active_doc/descriptions/method_argument_description.rb', line 218

def expectation_fail_to_s
  "satisfy given condition, got #{@failed_value.inspect}"
end

#to_rdocObject



222
223
224
# File 'lib/active_doc/descriptions/method_argument_description.rb', line 222

def to_rdoc
  "Complex Condition"
end