Class: SimpleService::ValidatesCommandsProperlyInherit
- Defined in:
- lib/simple_service/commands/validates_commands_properly_inherit.rb
Instance Attribute Summary
Attributes inherited from Command
Instance Method Summary collapse
Methods inherited from Command
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
#call ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/simple_service/commands/validates_commands_properly_inherit.rb', line 8 def call # valid commands inherit from Command and do not inherit from service # reject all valid commands and anything left over is invalid invalid_commands = provided_commands.to_a.reject do |command| command.ancestors.include?(SimpleService::Command) || command.ancestors.include?(SimpleService::Organizer) end if invalid_commands.any? error_msg = invalid_commands.join(', ') + ' - must inherit from SimpleService::Command' raise SimpleService::CommandParentClassInvalidError, error_msg end end |