Sha256: 9b84e6fe68667382302658c84ad32c6b81b78b2f70ae92fd118b20dd367a6be8

Contents?: true

Size: 432 Bytes

Versions: 12

Compression:

Stored size: 432 Bytes

Contents

# A collection of elements offering a Hash-like access based on
# their +id+.
class MissionControl::Jobs::IdentifiedElements
  include Enumerable

  delegate :[], :empty?, to: :elements
  delegate :each, :last, :length, to: :to_a

  def initialize
    @elements = HashWithIndifferentAccess.new
  end

  def <<(item)
    @elements[item.id] = item
  end

  def to_a
    @elements.values
  end

  private
    attr_reader :elements
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
mission_control-jobs-0.6.0 lib/mission_control/jobs/identified_elements.rb
mission_control-jobs-0.5.0 lib/mission_control/jobs/identified_elements.rb
mission_control-jobs-0.4.0 lib/mission_control/jobs/identified_elements.rb
mission_control-jobs-0.3.3 lib/mission_control/jobs/identified_elements.rb
mission_control-jobs-0.3.2 lib/mission_control/jobs/identified_elements.rb
mission_control-jobs-0.3.1 lib/mission_control/jobs/identified_elements.rb
mission_control-jobs-0.3.0 lib/mission_control/jobs/identified_elements.rb
mission_control-jobs-0.2.2 lib/mission_control/jobs/identified_elements.rb
mission_control-jobs-0.2.1 lib/mission_control/jobs/identified_elements.rb
mission_control-jobs-0.2.0 lib/mission_control/jobs/identified_elements.rb
mission_control-jobs-0.1.1 lib/mission_control/jobs/identified_elements.rb
mission_control-jobs-0.1.0 lib/mission_control/jobs/identified_elements.rb