Class: Treaty::Action::Versions::Collection

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/treaty/action/versions/collection.rb

Overview

Collection wrapper for sets of version factories.

Purpose

Provides a unified interface for working with collections of version factories. Uses Ruby Set internally for uniqueness but exposes Array-like interface.

Usage

Used internally by:

  • Versions::DSL (to store version factories)
  • Versions::Resolver (to find matching version)
  • Info::Builder (to build version information)

Methods

Delegates common collection methods to internal Set:

  • << - Add version factory
  • map - Iteration with transformation
  • find - Access by condition

Example

collection = Collection.new
collection << Factory.new(version: 1, default: true)
collection << Factory.new(version: 2, default: false)
collection.find { |f| f.default_result }  # => Factory(v1)

Instance Method Summary collapse

Constructor Details

#initialize(collection = Set.new) ⇒ Collection

Creates a new collection instance

Parameters:

  • collection (Set) (defaults to: Set.new)

    Initial collection (default: empty Set)



41
42
43
# File 'lib/treaty/action/versions/collection.rb', line 41

def initialize(collection = Set.new)
  @collection = collection
end