Class: Katalyst::Tables::Collection::Type::Date
- Inherits:
-
Value
- Object
- ActiveModel::Type::Value
- Value
- Katalyst::Tables::Collection::Type::Date
- Includes:
- Helpers::Range
- Defined in:
- lib/katalyst/tables/collection/type/date.rb
Constant Summary collapse
- ISO_DATE =
/\A(?<year>\d{4})-(?<month>\d\d)-(?<day>\d\d)\z/
Instance Attribute Summary
Attributes inherited from Value
Instance Method Summary collapse
Methods included from Helpers::Range
#cast, #deserialize, #serialize
Methods inherited from Value
#filter, #filter?, #filterable?, #initialize
Constructor Details
This class inherits a constructor from Katalyst::Tables::Collection::Type::Value
Instance Method Details
#suggestions(scope, attribute) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/katalyst/tables/collection/type/date.rb', line 27 def suggestions(scope, attribute) [ *super(scope, attribute, limit: 6, order: :desc), database_suggestion(attribute:, value: ::Date.current.beginning_of_week..), database_suggestion(attribute:, value: ::Date.current.beginning_of_month..), database_suggestion(attribute:, value: 1.month.ago.all_month), database_suggestion(attribute:, value: 1.year.ago.all_year), ] end |
#to_param(value) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/katalyst/tables/collection/type/date.rb', line 18 def to_param(value) case value when ::Date, ::DateTime, ::Time, ActiveSupport::TimeWithZone value.to_date.to_fs(:db) else super end end |
#type ⇒ Object
14 15 16 |
# File 'lib/katalyst/tables/collection/type/date.rb', line 14 def type :date end |