Class: RadiusRB::VendorCollection
- Inherits:
-
Array
- Object
- Array
- RadiusRB::VendorCollection
- Defined in:
- lib/radiusrb/vendor.rb
Instance Method Summary collapse
- #add(id, name) ⇒ Object
- #find_by_id(id) ⇒ Object
- #find_by_name(name) ⇒ Object
-
#initialize ⇒ VendorCollection
constructor
A new instance of VendorCollection.
Constructor Details
#initialize ⇒ VendorCollection
Returns a new instance of VendorCollection.
22 23 24 25 |
# File 'lib/radiusrb/vendor.rb', line 22 def initialize @collection = {} @revcollection = [] end |
Instance Method Details
#add(id, name) ⇒ Object
27 28 29 30 31 |
# File 'lib/radiusrb/vendor.rb', line 27 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
37 38 39 |
# File 'lib/radiusrb/vendor.rb', line 37 def find_by_id(id) @revcollection[id.to_i] end |
#find_by_name(name) ⇒ Object
33 34 35 |
# File 'lib/radiusrb/vendor.rb', line 33 def find_by_name(name) @collection[name] end |