Created
February 4, 2016 13:44
-
-
Save Exact1990/0347222e7a04cf3b0539 to your computer and use it in GitHub Desktop.
repositories
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module SmsChannelRepository | |
| extend ActiveSupport::Concern | |
| include BaseRepository | |
| module ClassMethods | |
| def active | |
| find_by(active: true) | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SmsChannel < ActiveRecord::Base | |
| include SmsChannelRepository | |
| validates :label, :title, uniqueness: true | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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