Class: ActiveCrew::Base
- Inherits:
-
Object
- Object
- ActiveCrew::Base
- Includes:
- Authorizable, Chainable, Combinable, Commandable, Lockable, Measurable, Respondable, Validatable
- Defined in:
- lib/active_crew/base.rb
Overview
Sidekiq Command class. Implements command pattern for Sidekiq. Helps to deconstruct application into micro services with command interface.
Command class file structure with two micro services (mailer and users):
app
commands
mailer
deliver_command.rb
users
create_command.rb
Command queues will be the following:
mailer
users
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#invoker ⇒ Object
readonly
Returns the value of attribute invoker.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(invoker, context = {}) ⇒ Base
constructor
A new instance of Base.
- #name ⇒ Object
- #perform ⇒ Object
Methods included from Commandable
Methods included from Chainable
Methods included from Combinable
#combine_command, #combine_commands
Methods included from Validatable
Methods included from Respondable
Methods included from Authorizable
Methods included from Lockable
Constructor Details
#initialize(invoker, context = {}) ⇒ Base
Returns a new instance of Base.
33 34 35 36 37 38 |
# File 'lib/active_crew/base.rb', line 33 def initialize(invoker, context = {}) @invoker = invoker # Should only symbolize key for @context = ActiveSupport::HashWithIndifferentAccess.new context @options = @context[:options] || {} end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
31 32 33 |
# File 'lib/active_crew/base.rb', line 31 def context @context end |
#invoker ⇒ Object (readonly)
Returns the value of attribute invoker.
31 32 33 |
# File 'lib/active_crew/base.rb', line 31 def invoker @invoker end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
31 32 33 |
# File 'lib/active_crew/base.rb', line 31 def @options end |
Instance Method Details
#execute ⇒ Object
44 45 46 |
# File 'lib/active_crew/base.rb', line 44 def execute perform end |
#name ⇒ Object
40 41 42 |
# File 'lib/active_crew/base.rb', line 40 def name @name ||= self.class.name.underscore.gsub(/_command/, '') end |
#perform ⇒ Object
48 49 |
# File 'lib/active_crew/base.rb', line 48 def perform end |