Sha256: fe2813520aab265f0e8fd0db871c939575b23ba915804042352382a034fa5871

Contents?: true

Size: 933 Bytes

Versions: 3

Compression:

Stored size: 933 Bytes

Contents

module Arpa
  module Repositories
    module Actions
      class Finder
        include Arpa::Repositories::Base

        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

        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

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

        def repository_class
          RepositoryAction
        end

      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
arpa-0.2.0 lib/arpa/repositories/actions/finder.rb
arpa-0.1.0 lib/arpa/repositories/actions/finder.rb
arpa-0.0.9 lib/arpa/repositories/actions/finder.rb