Class: SimpleService::ValidatesExpectedKeys

Inherits:
Command
  • Object
show all
Defined in:
lib/simple_service/commands/validates_expected_keys.rb

Instance Attribute Summary

Attributes inherited from Command

#context

Instance Method Summary collapse

Methods inherited from Command

#initialize

Methods included from ServiceBase::ClassMethods

#expects, #get_expects, #get_returns, #returns, #skip_validation

Methods included from ServiceBase::InstanceMethods

#all_context_keys, #define_getters_and_setters, #expects, #failed?, #failure!, #find_specified_return_keys, #organizer?, #return_context_with_success_status, #returns, #setup_call_chain, #skip_validation, #successful?, #symbolize_context_keys

Constructor Details

This class inherits a constructor from SimpleService::Command

Instance Method Details

#callObject



8
9
10
11
12
13
14
15
16
# File 'lib/simple_service/commands/validates_expected_keys.rb', line 8

def call
  arguments_not_included = expected_keys.to_a - provided_keys.to_a

  if arguments_not_included.any?
    error_msg = 'keys required by the organizer but not found in the context: ' +
      arguments_not_included.join(', ')
    raise ExpectedKeyError, error_msg
  end
end