class Vana::Element::BaseElement

methods for every element

Public Class Methods

new(hosts, *args) { |self| ... } click to toggle source
# File lib/vana/element.rb, line 8
def initialize(hosts, *args)
  @hosts = hosts
  @element_opts = {}
  @opts = {}

  yield self if block_given?
  setup(*args)
end

Public Instance Methods

action(_host, *_args) click to toggle source
# File lib/vana/element.rb, line 21
def action(_host, *_args)
  # nop
end
execute(*args) click to toggle source
# File lib/vana/element.rb, line 29
def execute(*args)
  puts "-- #{@element_opts[:name]}"
  @hosts.each do |host|
    output = action(host, *args)
    puts "#{host}: #{output.to_json}".colorize(output[:success] ? :light_green : :light_red)

    # TODO: need a better place to handle exceptions and keep going with the script
    # raise "Execution failed on '#{@element_opts[:name]}'" unless output[:success]
  end
end
name=(name) click to toggle source
# File lib/vana/element.rb, line 25
def name=(name)
  @element_opts[:name] = name
end
setup(*_args) click to toggle source
# File lib/vana/element.rb, line 17
def setup(*_args)
  # nop
end