Class: Kicker::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/kicker/job.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Job

Returns a new instance of Job.



23
24
25
26
27
# File 'lib/kicker/job.rb', line 23

def initialize(attributes)
  @exit_code = 0
  @output = ''
  attributes.each { |k,v| send("#{k}=", v) }
end

Instance Attribute Details

#commandObject

Returns the value of attribute command.



21
22
23
# File 'lib/kicker/job.rb', line 21

def command
  @command
end

#exit_codeObject

Returns the value of attribute exit_code.



21
22
23
# File 'lib/kicker/job.rb', line 21

def exit_code
  @exit_code
end

#outputObject

Returns the value of attribute output.



21
22
23
# File 'lib/kicker/job.rb', line 21

def output
  @output
end

Class Method Details

.attr_with_default(name, merge_hash = false, &default) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/kicker/job.rb', line 3

def self.attr_with_default(name, merge_hash = false, &default)
  # If `nil` this returns the `default`, unless explicitely set to `nil` by
  # the user.
  define_method(name) do
    if instance_variable_get("@#{name}_assigned")
      if assigned_value = instance_variable_get("@#{name}")
        merge_hash ? instance_eval(&default).merge(assigned_value) : assigned_value
      end
    else
      instance_eval(&default)
    end
  end
  define_method("#{name}=") do |value|
    instance_variable_set("@#{name}_assigned", true)
    instance_variable_set("@#{name}", value)
  end
end

Instance Method Details

#success?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/kicker/job.rb', line 29

def success?
  exit_code == 0
end