Sha256: 66488ec51c15a1491258f2aa5c65ad1ce4f5a9f2a6088f90d8298a6512d4525d

Contents?: true

Size: 576 Bytes

Versions: 2

Compression:

Stored size: 576 Bytes

Contents

module Headmin
  module Filter
    class Date < Headmin::Filter::Base
      OPERATORS = %w[eq not_eq gt gteq lt lteq between not_between in not_in is_null is_not_null]

      def cast_value(value)
        value.present? ? value.to_date : ::Date.current
      rescue
        raise TypeError, "The value that was passed to this filter is not a date"
      end

      def display_value(value)
        # This uses the default date format of headmin.
        # Can be overwritten by setting default date format of the application.
        I18n.l(value)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
headmin-0.5.1 app/models/headmin/filter/date.rb
headmin-0.5.0 app/models/headmin/filter/date.rb