Class: Murk::Model::StackCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/murk/model/stack_collection.rb

Instance Method Summary collapse

Constructor Details

#initializeStackCollection

Returns a new instance of StackCollection.



8
9
10
# File 'lib/murk/model/stack_collection.rb', line 8

def initialize
  @stacks = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_sym) ⇒ Object



31
32
33
# File 'lib/murk/model/stack_collection.rb', line 31

def method_missing(method_sym)
  @stacks.find { |stack| stack.name == method_sym.to_s }
end

Instance Method Details

#add(stack) ⇒ Object



12
13
14
15
# File 'lib/murk/model/stack_collection.rb', line 12

def add(stack)
  @stacks << stack
  stack.collection = self
end

#each(&block) ⇒ Object



17
18
19
# File 'lib/murk/model/stack_collection.rb', line 17

def each(&block)
  @stacks.each(&block)
end

#find_by_name(name, env: nil) ⇒ Object



21
22
23
24
25
# File 'lib/murk/model/stack_collection.rb', line 21

def find_by_name(name, env: nil)
  find do |stack|
    stack.name == name && stack.env == env
  end
end

#respond_to?(method_sym) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/murk/model/stack_collection.rb', line 27

def respond_to?(method_sym)
  @stacks.any? { |stack| stack.name == method_sym.to_s }
end