Class: ActiveCommand::Base
- Inherits:
-
Object
- Object
- ActiveCommand::Base
- Defined in:
- lib/active_command/base.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
- #execute_after_hooks ⇒ Object
- #execute_before_hooks ⇒ Object
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
- #run ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Base
52 53 54 55 56 57 58 |
# File 'lib/active_command/base.rb', line 52 def initialize( = {}) # @before_hooks = [] # @after_hooks = [] @instance_parameters = {} initialize_values!() define_methods! end |
Class Method Details
.inherited(base) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/active_command/base.rb', line 3 def self.inherited(base) base.class_variable_set(:@@parameter_definitions, {}) base.class_variable_set(:@@before_hooks, []) base.class_variable_set(:@@after_hooks, []) base.class_eval { extend ClassMethods } end |
Instance Method Details
#call ⇒ Object
66 |
# File 'lib/active_command/base.rb', line 66 def call; end |
#execute_after_hooks ⇒ Object
74 75 76 77 78 |
# File 'lib/active_command/base.rb', line 74 def execute_after_hooks self.class.class_variable_get(:@@after_hooks).each do |block| instance_exec(&block) end end |
#execute_before_hooks ⇒ Object
68 69 70 71 72 |
# File 'lib/active_command/base.rb', line 68 def execute_before_hooks self.class.class_variable_get(:@@before_hooks).each do |block| instance_exec(&block) end end |
#run ⇒ Object
60 61 62 63 64 |
# File 'lib/active_command/base.rb', line 60 def run execute_before_hooks call execute_after_hooks end |