Class: Servactory::Internals::Collection
- Inherits:
-
Object
- Object
- Servactory::Internals::Collection
- Extended by:
- Forwardable
- Defined in:
- lib/servactory/internals/collection.rb
Instance Method Summary collapse
- #except(*names) ⇒ Object
- #find_by(name:) ⇒ Object
-
#initialize(collection = Set.new) ⇒ Collection
constructor
A new instance of Collection.
- #names ⇒ Object
- #only(*names) ⇒ Object
Constructor Details
#initialize(collection = Set.new) ⇒ Collection
Returns a new instance of Collection.
10 11 12 |
# File 'lib/servactory/internals/collection.rb', line 10 def initialize(collection = Set.new) @collection = collection end |
Instance Method Details
#except(*names) ⇒ Object
18 19 20 |
# File 'lib/servactory/internals/collection.rb', line 18 def except(*names) Collection.new(filter { |internal| names.exclude?(internal.name) }) end |
#find_by(name:) ⇒ Object
26 27 28 |
# File 'lib/servactory/internals/collection.rb', line 26 def find_by(name:) find { |internal| internal.name == name } end |
#names ⇒ Object
22 23 24 |
# File 'lib/servactory/internals/collection.rb', line 22 def names map(&:name) end |
#only(*names) ⇒ Object
14 15 16 |
# File 'lib/servactory/internals/collection.rb', line 14 def only(*names) Collection.new(filter { |internal| names.include?(internal.name) }) end |