Module: ActiveCommand::Base::ClassMethods

Defined in:
lib/active_command/base.rb

Instance Method Summary collapse

Instance Method Details

#after(&block) ⇒ Object



35
36
37
# File 'lib/active_command/base.rb', line 35

def after(&block)
  base_class_after_hooks << block
end

#base_class_after_hooksObject



47
48
49
# File 'lib/active_command/base.rb', line 47

def base_class_after_hooks
  class_variable_get(:@@after_hooks)
end

#base_class_before_hooksObject



43
44
45
# File 'lib/active_command/base.rb', line 43

def base_class_before_hooks
  class_variable_get(:@@before_hooks)
end

#base_class_parametersObject



39
40
41
# File 'lib/active_command/base.rb', line 39

def base_class_parameters
  class_variable_get(:@@parameter_definitions)
end

#before(&block) ⇒ Object



31
32
33
# File 'lib/active_command/base.rb', line 31

def before(&block)
  base_class_before_hooks << block
end

#call(options = {}) ⇒ Object



11
12
13
14
15
# File 'lib/active_command/base.rb', line 11

def call(options = {})
  instance = new(options)
  instance.run
  instance
end

#optional(name, options = {}) ⇒ Object



24
25
26
27
28
29
# File 'lib/active_command/base.rb', line 24

def optional(name, options = {})
  base_class_parameters[name] = {
    type: options[:type],
    required: false
  }
end

#required(name, options = {}) ⇒ Object



17
18
19
20
21
22
# File 'lib/active_command/base.rb', line 17

def required(name, options = {})
  base_class_parameters[name] = {
    type: options[:type],
    required: true
  }
end