Class: Duple::Config::Command
- Inherits:
-
Object
- Object
- Duple::Config::Command
- Defined in:
- lib/duple/config/command.rb
Overview
Represents a command that can be executed in the source or target environment.
Constant Summary collapse
- SHELL =
'shell'
- HEROKU =
'heroku'
- VALID_TYPES =
[SHELL, HEROKU]
- SOURCE =
'source'
- TARGET =
'target'
- VALID_SUBJECTS =
[SOURCE, TARGET]
Instance Attribute Summary collapse
-
#command ⇒ Object
Returns the value of attribute command.
-
#subject ⇒ Object
Returns the value of attribute subject.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #heroku? ⇒ Boolean
-
#initialize(config_hash) ⇒ Command
constructor
A new instance of Command.
- #shell? ⇒ Boolean
- #source? ⇒ Boolean
- #target? ⇒ Boolean
Constructor Details
#initialize(config_hash) ⇒ Command
Returns a new instance of Command.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/duple/config/command.rb', line 15 def initialize(config_hash) @command = config_hash['command'] @type = config_hash['command_type'] @subject = config_hash['subject'] unless VALID_TYPES.include?(@type) raise ArgumentError.new("Invalid config: #{@type} is not a valid command type.") end unless VALID_SUBJECTS.include?(@subject) raise ArgumentError.new("Invalid config: #{@subject} is not a valid command subject.") end end |
Instance Attribute Details
#command ⇒ Object
Returns the value of attribute command.
13 14 15 |
# File 'lib/duple/config/command.rb', line 13 def command @command end |
#subject ⇒ Object
Returns the value of attribute subject.
13 14 15 |
# File 'lib/duple/config/command.rb', line 13 def subject @subject end |
#type ⇒ Object
Returns the value of attribute type.
13 14 15 |
# File 'lib/duple/config/command.rb', line 13 def type @type end |
Instance Method Details
#heroku? ⇒ Boolean
37 38 39 |
# File 'lib/duple/config/command.rb', line 37 def heroku? type == Duple::Config::Command::HEROKU end |
#shell? ⇒ Boolean
41 42 43 |
# File 'lib/duple/config/command.rb', line 41 def shell? type == Duple::Config::Command::SHELL end |