Class: Treaty::Action::Versions::Collection
- Inherits:
-
Object
- Object
- Treaty::Action::Versions::Collection
- 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 factorymap- Iteration with transformationfind- 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
-
#initialize(collection = Set.new) ⇒ Collection
constructor
Creates a new collection instance.
Constructor Details
#initialize(collection = Set.new) ⇒ Collection
Creates a new collection instance
41 42 43 |
# File 'lib/treaty/action/versions/collection.rb', line 41 def initialize(collection = Set.new) @collection = collection end |