Sha256: 7827a457d0158753978f09f08903f4c5aa4b29151a721a562d487f3e5bb693b5

Contents?: true

Size: 628 Bytes

Versions: 3

Compression:

Stored size: 628 Bytes

Contents

module Dune::Api
  ProjectPolicy        = ::ProjectPolicy
  ProjectPolicy::Scope = ::ProjectPolicy::Scope

  class Project < ::Project
    %i(created_at expires_at online_date).each do |name|
      # class << self
      #   def between_created_at(starts_at, ends_at)
      #     between_dates(:created_at, starts_at, ends_at)
      #   end
      # end
      define_singleton_method("between_#{name}") do |starts_at, ends_at|
        between_dates(name, starts_at, ends_at)
      end
    end

    private

    def self.between_dates(attribute, starts_at, ends_at)
      where(attribute => [starts_at..ends_at])
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dune-api-1.1.0 app/models/dune/api/project.rb
dune-api-1.0.2 app/models/dune/api/project.rb
dune-api-1.0.1 app/models/dune/api/project.rb