Class: Holidays::Definition::Context::Load
- Inherits:
-
Object
- Object
- Holidays::Definition::Context::Load
- Defined in:
- lib/holidays/definition/context/load.rb
Instance Method Summary collapse
- #call(region) ⇒ Object
-
#initialize(definition_merger, full_definitions_path) ⇒ Load
constructor
A new instance of Load.
Constructor Details
#initialize(definition_merger, full_definitions_path) ⇒ Load
Returns a new instance of Load.
5 6 7 8 |
# File 'lib/holidays/definition/context/load.rb', line 5 def initialize(definition_merger, full_definitions_path) @definition_merger = definition_merger @full_definitions_path = full_definitions_path end |
Instance Method Details
#call(region) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/holidays/definition/context/load.rb', line 10 def call(region) region_definition_file = "#{@full_definitions_path}/#{region}" require region_definition_file target_region_module = Module.const_get("Holidays").const_get(region.upcase) @definition_merger.call( region, target_region_module.holidays_by_month, target_region_module.custom_methods, ) target_region_module.defined_regions rescue NameError, LoadError => e raise UnknownRegionError.new(e), "Could not load region prefix: #{region.to_s}" end |