Class: Crystalball::MapGenerator::StrategiesCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/crystalball/map_generator/strategies_collection.rb

Overview

Manages map generation strategies

Instance Method Summary collapse

Constructor Details

#initialize(strategies = []) ⇒ StrategiesCollection

Returns a new instance of StrategiesCollection.



9
10
11
# File 'lib/crystalball/map_generator/strategies_collection.rb', line 9

def initialize(strategies = [])
  @strategies = strategies
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



21
22
23
# File 'lib/crystalball/map_generator/strategies_collection.rb', line 21

def method_missing(method_name, *args, &block)
  _strategies.public_send(method_name, *args, &block) || super
end

Instance Method Details

#respond_to_missing?(method_name, *_args) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/crystalball/map_generator/strategies_collection.rb', line 25

def respond_to_missing?(method_name, *_args)
  _strategies.respond_to?(method_name, false) || super
end

#run(example_group_map, example, &block) ⇒ Crystalball::ExampleGroupMap

Calls every strategy on the given example group map and returns the modified example group map

Parameters:

Returns:



16
17
18
19
# File 'lib/crystalball/map_generator/strategies_collection.rb', line 16

def run(example_group_map, example, &block)
  run_for_strategies(example_group_map, example, *_strategies.reverse, &block)
  example_group_map
end