Class: Zaikio::MissionControl::Jobs::Base

Inherits:
Base
  • Object
show all
Defined in:
lib/zaikio/mission_control/jobs/base.rb

Class Method Summary collapse

Class Method Details

.multiples?(part_name_or_klass) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/zaikio/mission_control/jobs/base.rb', line 28

def multiples?(part_name_or_klass)
  part_config(part_name_or_klass)[:multiple]
end

.part_config(part_name_or_klass) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/zaikio/mission_control/jobs/base.rb', line 11

def part_config(part_name_or_klass)
  @parts ||= {}
  part_name_or_klass = if part_name_or_klass.is_a?(Symbol)
                         part_name_or_klass.to_s.singularize.to_sym
                       else
                         part_name_or_klass.name.split("::").last.underscore.to_sym
                       end
  @parts[part_name_or_klass] or raise ArgumentError,
                                      "Part #{part_name_or_klass} could not be found in #{self.class.name}"
end

.part_klassesObject



22
23
24
25
26
# File 'lib/zaikio/mission_control/jobs/base.rb', line 22

def part_klasses
  parts.map do |name|
    Zaikio::MissionControl::Parts.const_get(name.to_s.classify)
  end
end

.partsObject



6
7
8
9
# File 'lib/zaikio/mission_control/jobs/base.rb', line 6

def parts
  @parts ||= {}
  @parts.keys
end

.required?(part_name_or_klass) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/zaikio/mission_control/jobs/base.rb', line 32

def required?(part_name_or_klass)
  part_config(part_name_or_klass)[:required]
end