Method: Wgit::Assertable#assert_respond_to

Defined in:
lib/wgit/assertable.rb

#assert_respond_to(obj_or_objs, methods, msg = nil) ⇒ Object

The obj_or_objs must respond_to? all of the given methods or an Exception is raised using msg, if provided.

Parameters:

  • obj_or_objs (Object, Enumerable#each)

    The object(s) to duck check.

  • methods (Array<Symbol>)

    The methods to :respond_to?.

  • msg (String) (defaults to: nil)

    The raised StandardError message, if provided.

Returns:

  • (Object)

    The given obj_or_objs on successful assertion.

Raises:

  • (StandardError)

    If the assertion fails.



84
85
86
87
88
89
90
91
92
93
94
# File 'lib/wgit/assertable.rb', line 84

def assert_respond_to(obj_or_objs, methods, msg = nil)
  methods = *methods

  if obj_or_objs.respond_to?(:each)
    obj_or_objs.each { |obj| _assert_respond_to(obj, methods, msg) }
  else
    _assert_respond_to(obj_or_objs, methods, msg)
  end

  obj_or_objs
end