Class: Radiustar::VendorCollection

Inherits:
Array
  • Object
show all
Defined in:
lib/radiustar/vendor.rb

Instance Method Summary collapse

Constructor Details

#initializeVendorCollection

Returns a new instance of VendorCollection.



5
6
7
8
# File 'lib/radiustar/vendor.rb', line 5

def initialize
  @collection = {}
  @revcollection = []
end

Instance Method Details

#add(id, name) ⇒ Object



10
11
12
13
14
# File 'lib/radiustar/vendor.rb', line 10

def add(id, name)
  @collection[name] ||= Vendor.new(name, id)
  @revcollection[id.to_i] ||= @collection[name]
  self << @collection[name]
end

#find_by_id(id) ⇒ Object



20
21
22
# File 'lib/radiustar/vendor.rb', line 20

def find_by_id(id)
  @revcollection[id.to_i]
end

#find_by_name(name) ⇒ Object



16
17
18
# File 'lib/radiustar/vendor.rb', line 16

def find_by_name(name)
  @collection[name]
end