6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/repository_manager/has_repository.rb', line 6
def has_repository(options = {})
has_many :sharings, through: :sharings_members, class_name: 'RepositoryManager::Sharing'
has_many :sharings_members, class_name: 'RepositoryManager::SharingsMember', as: :member, dependent: :destroy
has_many :sharings_owners, as: :owner, class_name: 'RepositoryManager::Sharing'
has_many :repo_items, as: :owner, class_name: 'RepositoryManager::RepoItem' has_many :shared_repo_items, through: :sharings, source: :repo_item, class_name: 'RepositoryManager::RepoItem'
if Rails::VERSION::MAJOR == 4
has_many :root_repo_items, -> { where ancestry: nil }, as: :owner, class_name: 'RepositoryManager::RepoItem'
has_many :root_shared_repo_items, -> { where ancestry: nil }, through: :sharings, source: :repo_item, class_name: 'RepositoryManager::RepoItem'
else
has_many :root_repo_items, where(ancestry: nil), as: :owner, class_name: 'RepositoryManager::RepoItem'
has_many :root_shared_repo_items, where(ancestry: nil), through: :sharings, source: :repo_item, class_name: 'RepositoryManager::RepoItem'
end
include RepositoryManager::HasRepository::LocalInstanceMethods
end
|