Module: ControllerCommands::Command
- Defined in:
- lib/controller_commands/command.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #errors ⇒ Object
- #initialize(incoming_params, context) ⇒ Object
- #perform ⇒ Object
- #render_success(output) ⇒ Object
- #success_message ⇒ Object
- #validate_params ⇒ Object
- #validated? ⇒ Boolean
- #validated_params ⇒ Object
Class Method Details
.included(base) ⇒ Object
44 45 46 |
# File 'lib/controller_commands/command.rb', line 44 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#errors ⇒ Object
57 58 59 |
# File 'lib/controller_commands/command.rb', line 57 def errors @result. end |
#initialize(incoming_params, context) ⇒ Object
48 49 50 51 |
# File 'lib/controller_commands/command.rb', line 48 def initialize(incoming_params, context) @incoming_params = incoming_params @context = context end |
#perform ⇒ Object
74 75 76 |
# File 'lib/controller_commands/command.rb', line 74 def perform self.class.perform(@context, validated_params) end |
#render_success(output) ⇒ Object
78 79 80 |
# File 'lib/controller_commands/command.rb', line 78 def render_success(output) self.class.execute_before_success_render(@context, output) end |
#success_message ⇒ Object
70 71 72 |
# File 'lib/controller_commands/command.rb', line 70 def self.class. end |
#validate_params ⇒ Object
65 66 67 68 |
# File 'lib/controller_commands/command.rb', line 65 def validate_params @result = self.class.validate(@context, @incoming_params) @result..count == 0 end |
#validated? ⇒ Boolean
53 54 55 |
# File 'lib/controller_commands/command.rb', line 53 def validated? !!@result end |
#validated_params ⇒ Object
61 62 63 |
# File 'lib/controller_commands/command.rb', line 61 def validated_params @result.output end |