Sha256: 002165e2b9a84047289d8ef47b4c5a4618fac094162f839762e162c725ab74a6

Contents?: true

Size: 597 Bytes

Versions: 6

Compression:

Stored size: 597 Bytes

Contents

require 'mongoid_occurrences/queries/query'

module MongoidOccurrences
  module Queries
    class OccursUntil < Query
      option :dtend_field, :dtend

      def initialize(base_criteria, date_time, options = {})
        @base_criteria = base_criteria
        @date_time = date_time
        @options = options
      end

      def criteria
        base_criteria.lte(dtend_field => adjusted_date_time)
      end

      private

      def adjusted_date_time
        date_time.instance_of?(Date) ? date_time.end_of_day : date_time
      end

      attr_reader :date_time, :options
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mongoid_occurrences-1.1.0 lib/mongoid_occurrences/queries/occurs_until.rb
mongoid_occurrences-1.0.4 lib/mongoid_occurrences/queries/occurs_until.rb
mongoid_occurrences-1.0.3 lib/mongoid_occurrences/queries/occurs_until.rb
mongoid_occurrences-1.0.2 lib/mongoid_occurrences/queries/occurs_until.rb
mongoid_occurrences-1.0.1 lib/mongoid_occurrences/queries/occurs_until.rb
mongoid_occurrences-1.0.0 lib/mongoid_occurrences/queries/occurs_until.rb