Module: ActsAsDaterange
- Included in:
- ActiveRecord::Base
- Defined in:
- lib/acts_as_daterange/version.rb,
lib/acts_as_daterange.rb
Constant Summary collapse
- VERSION =
"0.0.2"
Instance Method Summary collapse
-
#acts_as_expirable(*args, start_date: nil, end_date: nil) ⇒ Object
set your own custom start_date and end_date acts_as_daterange :started_at, :ended_at or acts_as_daterange start_date: :started_at, end_date: :ended_at.
Instance Method Details
#acts_as_expirable(*args, start_date: nil, end_date: nil) ⇒ Object
set your own custom start_date and end_date
acts_as_daterange :started_at, :ended_at
or
acts_as_daterange start_date: :started_at, end_date: :ended_at
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/acts_as_daterange.rb', line 18 def acts_as_expirable(*args, start_date: nil, end_date: nil) include Daterange if args.present? if start_date || end_date || args.count != 2 raise ArgumentError.new("ActsAsDaterange: must have both start_date and end_date") end start_column,expire_column = args elsif start_date || end_date if !start_date || !end_date raise ArgumentError.new("ActsAsDaterange: must have both start_date and end_date") end start_column,expire_column = start_date, end_date end self.daterange_config = { start_column: start_column || 'start_date', expire_column: expire_column || 'end_date' } end |