Class: Nuva::Repository

Inherits:
Object
  • Object
show all
Defined in:
lib/nuva/repository.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Repository

Returns a new instance of Repository.



7
8
9
# File 'lib/nuva/repository.rb', line 7

def initialize(data)
  @data = index_array_by_id(data)
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



5
6
7
# File 'lib/nuva/repository.rb', line 5

def data
  @data
end

Instance Method Details

#allObject



15
16
17
# File 'lib/nuva/repository.rb', line 15

def all
  @data.values
end

#by_ids(ids) ⇒ Object



19
20
21
# File 'lib/nuva/repository.rb', line 19

def by_ids(ids)
  ids.map { |x| find x }.compact
end

#find(id) ⇒ Object



11
12
13
# File 'lib/nuva/repository.rb', line 11

def find(id)
  @data[id]
end