Module: Adama::Command
- Defined in:
- lib/adama/command.rb
Overview
Extend class with module methods
class CollectUnderpantsCommand
include Adama::Command
def call
got_get_underpants()
end
def rollback
return_underpants_to_rightful_owner()
end
end
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(base) ⇒ Object
Internal: Install Command’s behavior in the given class.
Instance Method Summary collapse
-
#call ⇒ Object
Public instance method.
- #initialize(**kwargs) ⇒ Object
-
#rollback ⇒ Object
Public instance method.
-
#run ⇒ Object
Internal instance method.
Class Method Details
.included(base) ⇒ Object
Internal: Install Command’s behavior in the given class.
17 18 19 20 21 22 23 |
# File 'lib/adama/command.rb', line 17 def self.included(base) base.class_eval do prepend Validator extend ClassMethods attr_reader :kwargs end end |
Instance Method Details
#call ⇒ Object
Public instance method. Override this in classes this module is included in.
50 |
# File 'lib/adama/command.rb', line 50 def call; end |
#initialize(**kwargs) ⇒ Object
32 33 34 |
# File 'lib/adama/command.rb', line 32 def initialize(**kwargs) @kwargs = kwargs end |
#rollback ⇒ Object
Public instance method. Override this in classes this module is included in.
54 |
# File 'lib/adama/command.rb', line 54 def rollback; end |
#run ⇒ Object
Internal instance method. Called by both the call class method, and by the call method in the invoker. If it fails it raises a CommandError.
38 39 40 41 42 43 44 45 46 |
# File 'lib/adama/command.rb', line 38 def run tap(&:call) rescue => error raise Errors::CommandError.new( error: error, command: self, backtrace: error.backtrace ) end |