Class: SimpleService::Organizer
- Inherits:
-
Object
- Object
- SimpleService::Organizer
- Extended by:
- ServiceBase::ClassMethods
- Includes:
- ServiceBase::InstanceMethods
- Defined in:
- lib/simple_service/organizer.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
Class Method Summary collapse
Instance Method Summary collapse
- #commands ⇒ Object
- #execute ⇒ Object
-
#initialize(context = {}) ⇒ Organizer
constructor
A new instance of Organizer.
Methods included from ServiceBase::ClassMethods
Methods included from ServiceBase::InstanceMethods
#expects, #find_specified_return_keys, #returns, #setup_execute_chain
Constructor Details
#initialize(context = {}) ⇒ Organizer
Returns a new instance of Organizer.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/simple_service/organizer.rb', line 9 def initialize(context={}) @context = context ArgumentValidator.new( context: context, expects: expects, returns: returns, commands: commands ).execute setup_execute_chain end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
7 8 9 |
# File 'lib/simple_service/organizer.rb', line 7 def context @context end |
Class Method Details
.commands(*args) ⇒ Object
22 23 24 |
# File 'lib/simple_service/organizer.rb', line 22 def self.commands(*args) @commands = args end |
Instance Method Details
#commands ⇒ Object
26 27 28 |
# File 'lib/simple_service/organizer.rb', line 26 def commands self.class.instance_variable_get('@commands') end |
#execute ⇒ Object
30 31 32 33 34 |
# File 'lib/simple_service/organizer.rb', line 30 def execute commands.each do |command| @context.merge!(command.new(context).execute) end end |