Class: Arpa::Repositories::Actions::Finder

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/arpa/repositories/actions/finder.rb

Instance Method Summary collapse

Instance Method Details

#by_name_and_resource(name, resource_id) ⇒ Object



7
8
9
10
# File 'lib/arpa/repositories/actions/finder.rb', line 7

def by_name_and_resource(name, resource_id)
  record = repository_class.find_by(name: name, repository_resource_id: resource_id)
  mapper_instance.map_to_entity(record) if record
end

#mapper_instanceObject



22
23
24
# File 'lib/arpa/repositories/actions/finder.rb', line 22

def mapper_instance
  Arpa::DataMappers::ActionMapper.instance
end

#permission(resource_name, action_name, profile_ids) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/arpa/repositories/actions/finder.rb', line 12

def permission(resource_name, action_name, profile_ids)
  record = repository_class
           .distinct(true)
           .joins(:resource, roles: :profiles)
           .find_by(repository_profiles: { id: profile_ids },
                    repository_resources: { name: resource_name },
                    name: action_name)
  mapper_instance.map_to_entity(record) if record
end

#repository_classObject



26
27
28
# File 'lib/arpa/repositories/actions/finder.rb', line 26

def repository_class
  RepositoryAction
end