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
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
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/katalyst/tables/collection/type/date.rb', line 25 def suggestions(scope, attribute) _, model, column = model_and_column_for(scope, attribute) [ *super(scope, attribute, limit: 6, order: :desc), database_suggestion(attribute:, model:, column:, value: ::Date.current.beginning_of_week..), database_suggestion(attribute:, model:, column:, value: ::Date.current.beginning_of_month..), database_suggestion(attribute:, model:, column:, value: 1.month.ago.all_month), database_suggestion(attribute:, model:, column:, value: 1.year.ago.all_year), ] end |
#to_param(value) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/katalyst/tables/collection/type/date.rb', line 16 def to_param(value) case value when ::Date, ::DateTime, ::Time, ActiveSupport::TimeWithZone value.to_date.to_fs(:db) else super end end |
#type ⇒ Object
12 13 14 |
# File 'lib/katalyst/tables/collection/type/date.rb', line 12 def type :date end |