Updated

app/models / holiday.rb

A
48 lines of codes
9 methods
3.0 complexity/method
1 churn
27.39 complexity
0 duplications
class Holiday < ActiveRecord::Base
  1. Holiday has no descriptive comment
class << self def before_remove_const Thread.current[:__holiday__] = nil end def instance Thread.current[:__holiday__] ||= first_or_create(defaults) end def christmas?(today = Date.current) instance.christmas?(today) end def easter?(today = Date.current) instance.easter?(today) end private def defaults { christmas_start: '2017-12-22', christmas_end: '2018-01-04', easter_start: '2018-03-30', easter_end: '2018-04-09' } end end def christmas?(today = Date.current) christmas.cover?(today) end def easter?(today = Date.current) easter.cover?(today) end private def christmas christmas_start..christmas_end end def easter easter_start..easter_end end end