Skip to content

Instantly share code, notes, and snippets.

@Exact1990
Created February 4, 2016 13:44
Show Gist options
  • Select an option

  • Save Exact1990/0347222e7a04cf3b0539 to your computer and use it in GitHub Desktop.

Select an option

Save Exact1990/0347222e7a04cf3b0539 to your computer and use it in GitHub Desktop.
repositories
module SmsChannelRepository
extend ActiveSupport::Concern
include BaseRepository
module ClassMethods
def active
find_by(active: true)
end
end
end
class SmsChannel < ActiveRecord::Base
include SmsChannelRepository
validates :label, :title, uniqueness: true
end
module Network::DishRepository
extend ActiveSupport::Concern
include BaseRepository
included do
scope :with_delayed_start, -> { where(delayed_start: true) }
scope :actual_delayed_start, -> { where("delayed_start_date > :dt", dt: Time.current) }
scope :active, -> { where(active: true) }
scope :with_sections, -> { where.not(network_section_id: nil) }
scope :with_price, -> { joins(:network_rkeeper_dish).where('network_rkeeper_dishes.price_kopesks IS NOT NULL') }
scope :for_delivery_club, -> { active.with_sections.with_price }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment