forked from theforeman/foreman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnet.rb
43 lines (34 loc) · 839 Bytes
/
net.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
require_dependency "net/validations"
module Net
class Record
attr_accessor :hostname, :proxy, :logger
def initialize(opts = {})
# set all attributes
opts&.each do |k, v|
send("#{k}=", v) if respond_to?("#{k}=")
end
self.logger ||= Rails.logger
raise "Must define a proxy" if proxy.nil?
end
def inspect
to_s
end
# Do we have conflicting entries?
def conflicting?
!conflicts.empty?
end
# clears internal cache
def reload!
@conflicts = nil
end
# Compares two records by their attributes
def ==(other)
return false unless other.respond_to? :attrs
attrs == other.attrs
end
end
class Error < RuntimeError; end
class Conflict < RuntimeError
attr_accessor :type, :expected, :actual, :message
end
end