Sha256: 00dbbd1c314038ed8c296b3a5ffd4ed9fe918aa159888401b7cbd9428dc53cb9

Contents?: true

Size: 557 Bytes

Versions: 4

Compression:

Stored size: 557 Bytes

Contents

module Degica
  class Collection < Array
    # A collection is a group of {Degica::Collectable} instances which
    # can expose actions in the current context.
    #
    # Since collections are actionable, custom descriptions and
    # actions can be added when inheriting from this class.
    include Actionable

    def initialize(items = [])
      items.each do |item|
        item.collection = self
      end
      super(items)
    end

    def <<(item)
      item.collection = self
      push(item)
    end

    def actions
      []
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
degica-1.0.3 lib/degica/collection.rb
degica-1.0.2 lib/degica/collection.rb
degica-1.0.1 lib/degica/collection.rb
degica-1.0.0 lib/degica/collection.rb