kaize/mail_sandbox_web

View on GitHub
app/repositories/mail_application_repository.rb

Summary

Maintainability
A
0 mins
Test Coverage
module MailApplicationRepository
  extend ActiveSupport::Concern

  included do
    scope :active, where(:state => 'active')
    scope :web, active
    scope :find_by_credentials, ->(name, password){ where(:name => name).where(:password => password) }
    scope :ordered, ->{ web.order('id DESC') }
    scope :owner_is, ->(owner){ where(:owner_id => owner.id) }
    scope :available_for, ->(user){ where{ ( owner_id == user.id ) | ( id >> user.membered_application_ids ) } }
  end

end