Class: MuchRails::Action::BaseCommandResult

Inherits:
BaseResult
  • Object
show all
Defined in:
lib/much-rails/action/base_command_result.rb

Overview

MuchRails::Action::BaseCommandResult is a base result that, when executed, runs a generic controller command with some given args.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command_name, *command_args) ⇒ BaseCommandResult

Returns a new instance of BaseCommandResult.



13
14
15
16
# File 'lib/much-rails/action/base_command_result.rb', line 13

def initialize(command_name, *command_args)
  @command_name = command_name
  @command_args = command_args
end

Instance Attribute Details

#command_argsObject (readonly)

Returns the value of attribute command_args.



11
12
13
# File 'lib/much-rails/action/base_command_result.rb', line 11

def command_args
  @command_args
end

#command_nameObject (readonly)

Returns the value of attribute command_name.



11
12
13
# File 'lib/much-rails/action/base_command_result.rb', line 11

def command_name
  @command_name
end

Instance Method Details

#execute_blockObject

This block is called using ‘instance_exec` in the scope of the controller



19
20
21
# File 'lib/much-rails/action/base_command_result.rb', line 19

def execute_block
  ->(result){ public_send(result.command_name, *result.command_args) }
end