call method

  1. @override
bool call(
  1. Object? object, {
  2. C? cell,
  3. dynamic arguments,
  4. bool exception(
    1. TestRule<dynamic, Cell> rule,
    2. Exception e
    ) = TestRuleTrue.passed,
})

Validates the given action against this rule.

Automatically returns false if:

  • The host is unmodifiable and the action is in its modifiable set

Throws ArgumentError if:

Parameters:

  • object: The action to validate (must be a Function)
  • cell: The host Cell where the action will execute (required)
  • arguments: The function arguments (must be of type Arguments)
  • exception: Exception handler callback

Implementation

@override
bool call(Object? object, {C? cell, arguments, bool Function(TestRule rule, Exception e) exception = TestRuleTrue.passed}) {
  try {
    if (object is! Function) {
      throw ArgumentError.value(object, 'object', 'object not Function');
    } else if (cell == null) {
      throw ArgumentError.value(cell, 'host', 'host is null');
    } else if (arguments is! Arguments) {
      throw ArgumentError.value(arguments, 'arguments', 'arguments is not Arguments type');
    }
    return action(object, cell, arguments: arguments);
  } on Exception catch(e) {
    return exception(this, e);
  }
}