class CalendariumRomanum::Remote::V0::Denormalizer
Constants
- DaySchema
- YearSchema
Public Instance Methods
day(day_json)
click to toggle source
# File lib/calendarium-romanum/remote/v0/denormalizer.rb, line 5 def day(day_json) check day_json, DaySchema season_sym = day_json['season'].to_sym CalendariumRomanum::Day.new( date: Date.parse(day_json['date']), season: CalendariumRomanum::Seasons.all.find {|s| s.symbol == season_sym}, season_week: day_json['season_week'], celebrations: day_json['celebrations'].collect do |c| colour_sym = c['colour'].to_sym CalendariumRomanum::Celebration.new( c['title'], CalendariumRomanum::Ranks[c['rank_num']], CalendariumRomanum::Colours.all.find {|c| c.symbol == colour_sym } ) end ) end
year(year_json)
click to toggle source
# File lib/calendarium-romanum/remote/v0/denormalizer.rb, line 26 def year(year_json) check year_json, YearSchema # no denormalization takes place year_json end
Protected Instance Methods
check(data, schema)
click to toggle source
# File lib/calendarium-romanum/remote/v0/denormalizer.rb, line 35 def check(data, schema) errors = schema.call(data).errors unless errors.empty? raise InvalidDataError.new "Invalid data: #{errors.to_h}" end end