Class: Arpa::Repositories::Profiles::Finder

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

Instance Method Summary collapse

Instance Method Details

#allObject



12
13
14
15
16
# File 'lib/arpa/repositories/profiles/finder.rb', line 12

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

#all_by_entity(entity_id, entity_class) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/arpa/repositories/profiles/finder.rb', line 18

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

#find(id) ⇒ Object



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

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

#mapper_instanceObject



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

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

#repository_classObject



30
31
32
# File 'lib/arpa/repositories/profiles/finder.rb', line 30

def repository_class
  RepositoryProfile
end