Module: ForemanOpenscap::PolicyCommon
- Extended by:
- ActiveSupport::Concern
- Included in:
- Policy
- Defined in:
- app/models/concerns/foreman_openscap/policy_common.rb
Instance Method Summary collapse
- #cron_line_split ⇒ Object
- #update_period_attrs ⇒ Object
- #valid_cron_line ⇒ Object
- #valid_day_of_month ⇒ Object
- #valid_weekday ⇒ Object
Instance Method Details
#cron_line_split ⇒ Object
9 10 11 |
# File 'app/models/concerns/foreman_openscap/policy_common.rb', line 9 def cron_line_split cron_line.to_s.split(' ') end |
#update_period_attrs ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'app/models/concerns/foreman_openscap/policy_common.rb', line 31 def update_period_attrs case period when 'monthly' erase_period_attrs(%w[cron_line weekday]) when 'weekly' erase_period_attrs(%w[cron_line day_of_month]) when 'custom' erase_period_attrs(%w[weekday day_of_month]) end end |
#valid_cron_line ⇒ Object
13 14 15 16 17 |
# File 'app/models/concerns/foreman_openscap/policy_common.rb', line 13 def valid_cron_line if period == 'custom' errors.add(:cron_line, _("does not consist of 5 parts separated by space")) unless cron_line_split.size == 5 end end |
#valid_day_of_month ⇒ Object
25 26 27 28 29 |
# File 'app/models/concerns/foreman_openscap/policy_common.rb', line 25 def valid_day_of_month if period == 'monthly' errors.add(:day_of_month, _("must be between 1 and 31")) if !day_of_month || (day_of_month < 1 || day_of_month > 31) end end |
#valid_weekday ⇒ Object
19 20 21 22 23 |
# File 'app/models/concerns/foreman_openscap/policy_common.rb', line 19 def valid_weekday if period == 'weekly' errors.add(:weekday, _("is not a valid value")) unless Date::DAYNAMES.map(&:downcase).include? weekday end end |