Class: Superhosting::ScriptExecutor::Base

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/superhosting/script_executor/base.rb

Direct Known Subclasses

Container

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#create_conf, #erb, #instance_variables_to_hash, #remove_line_from_file, #write_if_not_exist

Constructor Details

#initialize(model:, lib:, config:, **kwargs) ⇒ Base

Returns a new instance of Base.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/superhosting/script_executor/base.rb', line 9

def initialize(model:, lib:, config:, **kwargs)
  kwargs.each do |k, v|
    instance_variable_set("@#{k}", v)
    self.class.class_eval("attr_accessor :#{k}")
  end

  self.commands = []
  self.model = model
  self.lib = lib
  self.config = config
end

Instance Attribute Details

#commandsObject

Returns the value of attribute commands.



6
7
8
# File 'lib/superhosting/script_executor/base.rb', line 6

def commands
  @commands
end

#configObject

Returns the value of attribute config.



7
8
9
# File 'lib/superhosting/script_executor/base.rb', line 7

def config
  @config
end

#libObject

Returns the value of attribute lib.



7
8
9
# File 'lib/superhosting/script_executor/base.rb', line 7

def lib
  @lib
end

#modelObject

Returns the value of attribute model.



7
8
9
# File 'lib/superhosting/script_executor/base.rb', line 7

def model
  @model
end

Instance Method Details

#execute(script) ⇒ Object



21
22
23
# File 'lib/superhosting/script_executor/base.rb', line 21

def execute(script)
  self.instance_eval(script)
end