Class: Medcon::Repository
- Inherits:
-
Object
- Object
- Medcon::Repository
show all
- Defined in:
- lib/medcon/repository.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Repository.
7
8
9
10
11
12
13
14
15
|
# File 'lib/medcon/repository.rb', line 7
def initialize(data)
@all = data
@index = {}
data.each do |item|
index_keys(item).each do |key|
@index[normalize_key(key)] = item
end
end
end
|
Instance Attribute Details
#all ⇒ Object
Returns the value of attribute all.
5
6
7
|
# File 'lib/medcon/repository.rb', line 5
def all
@all
end
|
Instance Method Details
#by_ids(ids) ⇒ Object
21
22
23
|
# File 'lib/medcon/repository.rb', line 21
def by_ids(ids)
ids.map { |x| find x }.compact
end
|
#find(id) ⇒ Object
17
18
19
|
# File 'lib/medcon/repository.rb', line 17
def find(id)
@index[normalize_key(id)]
end
|
#inspect ⇒ Object
25
26
27
|
# File 'lib/medcon/repository.rb', line 25
def inspect
"#<#{self.class} count=#{all.count}>"
end
|