Class: Net::Record
Direct Known Subclasses
Constant Summary
Constants included from Validations
Validations::IP_REGEXP, Validations::MAC_REGEXP
Instance Attribute Summary collapse
-
#hostname ⇒ Object
Returns the value of attribute hostname.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#proxy ⇒ Object
Returns the value of attribute proxy.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Compares two records by their attributes.
-
#conflicting? ⇒ Boolean
Do we have conflicting entries?.
-
#initialize(opts = {}) ⇒ Record
constructor
A new instance of Record.
- #inspect ⇒ Object
-
#reload! ⇒ Object
clears internal cache.
Methods included from Validations
normalize_ip, normalize_mac, #validate_ip, #validate_mac, #validate_network
Constructor Details
#initialize(opts = {}) ⇒ Record
Returns a new instance of Record
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/net.rb', line 8 def initialize opts = {} # set all attributes opts.each do |k,v| eval("self.#{k}= v") if self.respond_to?("#{k}=") end if opts raise Net::LeaseConflict.new("#{self.mac}/#{self.ip}") if opts['state'] self.logger ||= Rails.logger raise "Must define a hostname" if hostname.blank? raise "Must define a proxy" if proxy.nil? end |
Instance Attribute Details
#hostname ⇒ Object
Returns the value of attribute hostname
6 7 8 |
# File 'lib/net.rb', line 6 def hostname @hostname end |
#logger ⇒ Object
Returns the value of attribute logger
6 7 8 |
# File 'lib/net.rb', line 6 def logger @logger end |
#proxy ⇒ Object
Returns the value of attribute proxy
6 7 8 |
# File 'lib/net.rb', line 6 def proxy @proxy end |
Instance Method Details
#==(other) ⇒ Object
Compares two records by their attributes
36 37 38 39 |
# File 'lib/net.rb', line 36 def == other return false unless other.respond_to? :attrs self.attrs == other.attrs end |
#conflicting? ⇒ Boolean
Do we have conflicting entries?
26 27 28 |
# File 'lib/net.rb', line 26 def conflicting? !conflicts.empty? end |
#inspect ⇒ Object
21 22 23 |
# File 'lib/net.rb', line 21 def inspect to_s end |
#reload! ⇒ Object
clears internal cache
31 32 33 |
# File 'lib/net.rb', line 31 def reload! @conflicts = nil end |