Class: Radiustar::AttributesCollection
- Inherits:
-
Array
- Object
- Array
- Radiustar::AttributesCollection
- Defined in:
- lib/radiustar/dictionary/attributes.rb
Instance Attribute Summary collapse
-
#vendor ⇒ Object
Returns the value of attribute vendor.
Instance Method Summary collapse
- #add(name, id, type) ⇒ Object
- #find_by_id(id) ⇒ Object
- #find_by_name(name) ⇒ Object
-
#initialize(vendor = nil) ⇒ AttributesCollection
constructor
A new instance of AttributesCollection.
- #vendor? ⇒ Boolean
Constructor Details
#initialize(vendor = nil) ⇒ AttributesCollection
Returns a new instance of AttributesCollection.
7 8 9 10 11 |
# File 'lib/radiustar/dictionary/attributes.rb', line 7 def initialize vendor=nil @collection = {} @revcollection = {} @vendor = vendor if vendor end |
Instance Attribute Details
#vendor ⇒ Object
Returns the value of attribute vendor.
5 6 7 |
# File 'lib/radiustar/dictionary/attributes.rb', line 5 def vendor @vendor end |
Instance Method Details
#add(name, id, type) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/radiustar/dictionary/attributes.rb', line 13 def add(name, id, type) if vendor? @collection[name] ||= Attribute.new(name, id.to_i, type, @vendor) else @collection[name] ||= Attribute.new(name, id.to_i, type) end @revcollection[id.to_i] ||= @collection[name] self << @collection[name] end |
#find_by_id(id) ⇒ Object
27 28 29 |
# File 'lib/radiustar/dictionary/attributes.rb', line 27 def find_by_id(id) @revcollection[id] end |
#find_by_name(name) ⇒ Object
23 24 25 |
# File 'lib/radiustar/dictionary/attributes.rb', line 23 def find_by_name(name) @collection[name] end |
#vendor? ⇒ Boolean
31 32 33 |
# File 'lib/radiustar/dictionary/attributes.rb', line 31 def vendor? !!@vendor end |