Class: KBuilder::Commands::BaseCommand
- Inherits:
-
Object
- Object
- KBuilder::Commands::BaseCommand
- Includes:
- KLog::Logging
- Defined in:
- lib/k_builder/commands/base_command.rb
Overview
Base command for single responsibility actions that can be fired from methods in the builder.
Uses the command pattern
Direct Known Subclasses
Instance Attribute Summary collapse
-
#builder ⇒ Object
Returns the value of attribute builder.
-
#valid ⇒ Object
Returns the value of attribute valid.
Instance Method Summary collapse
- #debug(title: nil) ⇒ Object
- #guard(message) ⇒ Object
-
#initialize(**opts) ⇒ BaseCommand
constructor
A new instance of BaseCommand.
- #valid? ⇒ Boolean
Constructor Details
#initialize(**opts) ⇒ BaseCommand
Returns a new instance of BaseCommand.
15 16 17 18 |
# File 'lib/k_builder/commands/base_command.rb', line 15 def initialize(**opts) @builder = opts[:builder] @valid = true end |
Instance Attribute Details
#builder ⇒ Object
Returns the value of attribute builder.
12 13 14 |
# File 'lib/k_builder/commands/base_command.rb', line 12 def builder @builder end |
#valid ⇒ Object
Returns the value of attribute valid.
13 14 15 |
# File 'lib/k_builder/commands/base_command.rb', line 13 def valid @valid end |
Instance Method Details
#debug(title: nil) ⇒ Object
30 31 32 33 |
# File 'lib/k_builder/commands/base_command.rb', line 30 def debug(title: nil) log.section_heading(title) if title debug_values if respond_to?(:debug_values) end |
#guard(message) ⇒ Object
20 21 22 23 24 |
# File 'lib/k_builder/commands/base_command.rb', line 20 def guard() # THIS SHOULD ONLY LOG IF DEBUGGING IS TURNED ON log.error() @valid = false end |
#valid? ⇒ Boolean
26 27 28 |
# File 'lib/k_builder/commands/base_command.rb', line 26 def valid? @valid end |