Class: Preference
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Preference
- Defined in:
- app/models/preference.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.due_styles ⇒ Object
9 10 11 |
# File 'app/models/preference.rb', line 9 def self.due_styles { :due_in_n_days => 0, :due_on => 1 } end |
.themes ⇒ Object
5 6 7 |
# File 'app/models/preference.rb', line 5 def self.themes { :black => 'black', :light_blue => 'light_blue' } end |
Instance Method Details
#format_date(date) ⇒ Object
32 33 34 |
# File 'app/models/preference.rb', line 32 def format_date(date) return date ? date.in_time_zone(time_zone).strftime("#{date_format}") : '' end |
#hide_completed_actions? ⇒ Boolean
13 14 15 |
# File 'app/models/preference.rb', line 13 def hide_completed_actions? return show_number_completed == 0 end |
#parse_date(s) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/models/preference.rb', line 17 def parse_date(s) return nil if s.blank? date = nil if s.is_a?(Time) date = s.to_date elsif s.is_a?(String) date = Date.strptime(s, date_format) else raise ArgumentError.new("Bad argument type:#{s.class}") end date.in_time_zone(time_zone).beginning_of_day end |