Sha256: 5b295b1f14be80a501da88d5870055d02cd5b6aa0fe6121dd32c6880c6d875e2

Contents?: true

Size: 904 Bytes

Versions: 1

Compression:

Stored size: 904 Bytes

Contents

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

        def find(id)
          record = repository_class.find(id)
          mapper_instance.map_to_entity(record)
        end

        def all
          repository_class.all.collect do |record|
            mapper_instance.map_to_entity(record)
          end
        end

        def all_by_entity(entity_id, entity_class)
          repository_class
            .where("( (entity_id is null AND entity_class is null) OR (entity_id = '#{entity_id}' AND entity_class = '#{entity_class}') )")
            .collect do |record|
            mapper_instance.map_to_entity(record)
          end
        end

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

        def repository_class
          RepositoryProfile
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
arpa-0.3.0 lib/arpa/repositories/profiles/finder.rb