Class: SimpleService::Command
- Inherits:
-
Object
- Object
- SimpleService::Command
- Extended by:
- ServiceBase::ClassMethods
- Includes:
- ServiceBase::InstanceMethods
- Defined in:
- lib/simple_service/command.rb
Direct Known Subclasses
ValidatesCommandsNotEmpty, ValidatesCommandsProperlyInherit, ValidatesExpectedKeys
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
Instance Method Summary collapse
-
#call ⇒ Object
call is where the command’s behavior is defined call should be overriden by whatever class inherits from this class.
-
#initialize(context = {}) ⇒ Command
constructor
A new instance of Command.
Methods included from ServiceBase::ClassMethods
expects, returns, skip_validation
Methods included from ServiceBase::InstanceMethods
#all_specified_context_keys, #define_getters_and_setters, #expects, #find_specified_return_keys, #returns, #setup_call_chain, #skip_validation, #symbolize_context_keys
Constructor Details
#initialize(context = {}) ⇒ Command
Returns a new instance of Command.
9 10 11 12 13 14 15 16 17 |
# File 'lib/simple_service/command.rb', line 9 def initialize(context={}) @context = context setup_call_chain define_getters_and_setters unless skip_validation ValidatesExpectedKeys.new(provided_keys: context.keys).call end end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
7 8 9 |
# File 'lib/simple_service/command.rb', line 7 def context @context end |
Instance Method Details
#call ⇒ Object
call is where the command’s behavior is defined call should be overriden by whatever class inherits from this class
22 23 24 25 |
# File 'lib/simple_service/command.rb', line 22 def call error_msg = "#{self.class} - does not define a call method" raise SimpleService::CallNotDefinedError , error_msg end |