Module: DayOffs::Core
- Defined in:
- lib/day_offs/core.rb
Class Method Summary collapse
Class Method Details
.objectize_sources ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/day_offs/core.rb', line 5 def objectize_sources DayOffs.used_sources.each do |country, year_sources_hash| DayOffs.const_set(country, Class.new).instance_eval do @sources = year_sources_hash @country = country def fetch(year, source = nil) raise DayOffs::Errors::UnsupportedYearError unless @sources[year] source = @sources[year].find { |s| s.source_name == source } || @sources[year].first source.call(year, @country) end end end end |