internetdata 2.10.0 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8682eb2a09e7c95b8a6bafe0c2849783249c6e1cc458722aa4b2b210453a4c5f
4
- data.tar.gz: 50f5a7facc448be5f76a82db05924ac3b7ceabd1617315e0fc0f786006ada7e9
3
+ metadata.gz: ce756f64a41cc04c13ce1f52bc59602f25e3073d9df15c7406ae8fe32624b471
4
+ data.tar.gz: 86446f891168900f4962c63fd323be24aedf51f487031ea268fc51ae9e42f37f
5
5
  SHA512:
6
- metadata.gz: ea33930ef4ba1e8e1c70a7154d19fb3f5f75d5e4da63e914182a50db6577df4c642dc8945c3f277969f278b959b1e17d25e253a64de8b2b64c4daa19b355efc4
7
- data.tar.gz: d7475a144284fb3a2cf63fad78a6c745218e98f103ea1ac2d4fd084475338ace705bb22f9bc6848bbaf445a4865b9901c5535f24cc0ba20e799820be99d3ae52
6
+ metadata.gz: fc926de1ae541dc84e982042b8f9b4ac8e63afb3a63b1db5fcf68c8cebb9de21ba50a60fe3bceca6642539e158251208934ade81781c93a5b615c6c5558ef184
7
+ data.tar.gz: 46d95d71b0ad5d8e6ad4c90233f3bcabd4405d44d15141121f460c388605fdecb14b7b5e3a0da27974726bdb149758a0a3b96c989d722d35427f02ec1b3f1583
data/README.md CHANGED
@@ -61,7 +61,7 @@ domain.is_registered # => true
61
61
  domain.dns # its records, on a paid plan
62
62
  ```
63
63
 
64
- Both are sent as you give them, and the API reads `AS9009` and an internationalized domain too. Neither is cached.
64
+ Both are sent as you give them, and the API reads `AS9009` and an internationalized domain too. Neither is cached. `lookup` takes an IP address alone, and raises a `:bad_request` for anything else before sending it.
65
65
 
66
66
  ### Your own address
67
67
 
@@ -30,6 +30,11 @@ module InternetData
30
30
  (addr.ipv4? ? v4 : v6).any? { |range| range.include?(addr) }
31
31
  end
32
32
 
33
+ # Whether `ip` reads as one IP address; a prefix is not one.
34
+ def address?(ip)
35
+ !parse(ip).nil?
36
+ end
37
+
33
38
  # The IPv4 address an IPv4-mapped IPv6 address (::ffff:a.b.c.d, in any
34
39
  # spelling) carries, dotted, and any other address as given. A server
35
40
  # listening on :: sees every IPv4 visitor in that form, which read whole is
@@ -89,6 +89,8 @@ module InternetData
89
89
  #
90
90
  # @param retries [Integer, nil] extra attempts, for THIS call only.
91
91
  # @param timeout [Numeric, nil] seconds each attempt may take, for THIS call only.
92
+ # @raise [Error] `:bad_request`, before any request, for anything but an IP
93
+ # address: {#lookup_asn} and {#lookup_domain} look an AS and a domain up.
92
94
  # @return [Result]
93
95
  def lookup(ip, retries: nil, timeout: nil)
94
96
  # Here as well as in the transport: a bogon or a cached answer returns before any request.
@@ -96,6 +98,12 @@ module InternetData
96
98
  Retries.checked_count(retries) unless retries.nil?
97
99
  # Judged, cached and sent as the IPv4 address it carries, if it is mapped.
98
100
  ip = Bogon.unmapped(ip)
101
+ # The API answers an AS or a domain at this path too, as an answer this call
102
+ # cannot read, so one is refused unsent rather than retried as unreadable.
103
+ unless Bogon.address?(ip)
104
+ raise Error.new(:bad_request, "'#{ip}' is not an IP address: look up an AS with lookup_asn, " \
105
+ 'and a domain with lookup_domain')
106
+ end
99
107
  return Bogon.result(ip) if Bogon.bogon?(ip)
100
108
 
101
109
  loop do
@@ -177,7 +177,7 @@ module InternetData
177
177
  @ignore_operation_servers = false
178
178
  @inject_format = false
179
179
  @force_ending_format = false
180
- @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
180
+ @logger = defined?(::Rails) ? ::Rails.logger : Logger.new(STDOUT)
181
181
 
182
182
  yield(self) if block_given?
183
183
  end
@@ -0,0 +1,148 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InternetData
4
+ module Middleware
5
+ # Deciding whether an answer is worth blocking.
6
+ #
7
+ # A condition is written in the shape of a served answer and keyed by the
8
+ # same names the API uses, so what you write here reads like what you get
9
+ # back. Symbol and string keys both work.
10
+ #
11
+ # { location: { country: %w[CU IR KP] } }
12
+ # { asn: { type: 'hosting' } }
13
+ # { is_resproxy: true, resproxy: { hits: { gte: 5 } } }
14
+ # { is_vpn: true, vpn: { provider: 'nordvpn' } }
15
+ # [{ is_tor: true }, { is_resproxy: true }] # a list is OR
16
+ #
17
+ # A value may be a scalar (equality, strings without regard to case), an
18
+ # Array meaning any-of, a Hash of `gte`/`gt`/`lte`/`lt` bounding a number,
19
+ # or a nested condition. A member set to `false` or `nil` is ignored
20
+ # entirely - a condition states the positive signals you act on, so there is
21
+ # no way to write "block when this is false", which would otherwise read as
22
+ # blocking everybody.
23
+ module Condition
24
+ BOUND_KEYS = %w[gte gt lte lt].freeze
25
+
26
+ module_function
27
+
28
+ # Whether an answer satisfies the condition, and should therefore be
29
+ # blocked.
30
+ def matches?(condition, result)
31
+ Array(wrap(condition)).any? { |one| matches_object?(one, result.raw) }
32
+ end
33
+
34
+ # The members a condition names that this answer did not carry: a
35
+ # top-level member, or a paid one inside an object every plan gets, by its
36
+ # path (`location.city`).
37
+ #
38
+ # A field your plan does not include is absent rather than false, so a
39
+ # condition naming one can never match and the block would silently never
40
+ # fire. An empty object (`{}`) is a real answer meaning the flag above it
41
+ # is false, so nothing inside one is reported: `vpn` empty is not a plan
42
+ # gap. A populated object carries every member the plan includes, so a
43
+ # member missing there is one.
44
+ #
45
+ # A locally answered bogon needs no special case: it is synthesized in the
46
+ # widest shape, so every member is present and nothing reads as missing.
47
+ def missing_members(condition, result)
48
+ missing = []
49
+ wrap(condition).each { |one| collect_missing(one, result.raw, '', missing) }
50
+ missing
51
+ end
52
+
53
+ # Refuse a condition that constrains nothing.
54
+ #
55
+ # Ignoring `false` means `{ is_vpn: false }` and `{}` have no terms left
56
+ # to satisfy, so they would match every answer and block all traffic.
57
+ # Nobody writes that on purpose, and failing when the middleware is built
58
+ # beats discovering it in production.
59
+ def validate!(condition)
60
+ return if condition.nil?
61
+
62
+ wrap(condition).each do |one|
63
+ next unless constraint_count(one).zero?
64
+
65
+ raise ArgumentError,
66
+ "internetdata: block condition #{one.inspect} constrains nothing, which " \
67
+ 'would block every request; a member set to false or nil is ignored, so ' \
68
+ 'state the positive signals you act on'
69
+ end
70
+ end
71
+
72
+ # How many leaf constraints a condition actually carries.
73
+ def constraint_count(condition)
74
+ case condition
75
+ when nil, false then 0
76
+ when Hash
77
+ bound?(condition) ? 1 : condition.values.sum { |v| constraint_count(v) }
78
+ when Array then condition.sum { |v| constraint_count(v) }
79
+ else 1
80
+ end
81
+ end
82
+
83
+ def wrap(condition)
84
+ condition.is_a?(Array) ? condition : [condition]
85
+ end
86
+
87
+ def collect_missing(condition, value, prefix, missing)
88
+ condition.each do |member, want|
89
+ next if constraint_count(want).zero?
90
+
91
+ path = "#{prefix}#{member}"
92
+ unless value.key?(member.to_s)
93
+ missing << path unless missing.include?(path)
94
+ next
95
+ end
96
+ got = value[member.to_s]
97
+ next unless want.is_a?(Hash) && !bound?(want) && got.is_a?(Hash) && !got.empty?
98
+
99
+ collect_missing(want, got, "#{path}.", missing)
100
+ end
101
+ end
102
+
103
+ def matches_object?(condition, value)
104
+ condition.all? do |member, want|
105
+ next true if constraint_count(want).zero?
106
+
107
+ matches_value?(want, value.is_a?(Hash) ? value[member.to_s] : nil)
108
+ end
109
+ end
110
+
111
+ # An ABSENT member arrives here as nil, which is exactly what "not in your
112
+ # plan" looks like. Every branch below must therefore reject it, which is
113
+ # what makes an unserved member fail a match rather than pass it.
114
+ def matches_value?(want, got)
115
+ case want
116
+ when Array then want.any? { |entry| matches_value?(entry, got) }
117
+ when Hash
118
+ bound?(want) ? matches_bound?(want, got) : matches_object?(want, got)
119
+ when String
120
+ # Providers are lowercase slugs and countries uppercase codes on the
121
+ # wire, and a caller should not have to know which, so a string
122
+ # compares without case.
123
+ got.is_a?(String) && want.casecmp?(got)
124
+ when true, false then want == got
125
+ when Numeric then got.is_a?(Numeric) && !got.is_a?(TrueClass) && want == got
126
+ else want == got
127
+ end
128
+ end
129
+
130
+ def matches_bound?(bound, got)
131
+ return false unless got.is_a?(Numeric)
132
+
133
+ normalized = bound.transform_keys(&:to_s)
134
+ return false if normalized['gte'] && got < normalized['gte']
135
+ return false if normalized['gt'] && got <= normalized['gt']
136
+ return false if normalized['lte'] && got > normalized['lte']
137
+
138
+ !(normalized['lt'] && got >= normalized['lt'])
139
+ end
140
+
141
+ def bound?(value)
142
+ return false unless value.is_a?(Hash)
143
+
144
+ !value.empty? && value.keys.all? { |k| BOUND_KEYS.include?(k.to_s) }
145
+ end
146
+ end
147
+ end
148
+ end
@@ -0,0 +1,181 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'condition'
4
+
5
+ module InternetData
6
+ # The framework-agnostic half of a web middleware: resolve a client address,
7
+ # classify it, and decide whether the condition matched.
8
+ #
9
+ # An adapter - the internetdata-rails gem - keeps only the parts that are
10
+ # genuinely framework-shaped and shares everything here, so the shared
11
+ # conformance corpus is asserted once for Ruby rather than once per framework.
12
+ module Middleware
13
+ # What a middleware attached to the request, whether or not it succeeded.
14
+ Lookup = Struct.new(:blocked, :ip, :result, :error, keyword_init: true) do
15
+ # Whether the condition matched. Always false when none was configured.
16
+ def blocked?
17
+ blocked == true
18
+ end
19
+ end
20
+
21
+ # Enough of an incoming request for a selector to work with, whatever
22
+ # framework it came from. An adapter supplies one of these per request.
23
+ RequestView = Struct.new(:header, :framework_ip, keyword_init: true)
24
+
25
+ # Defaults set for a request path rather than for a script: failing open
26
+ # quickly beats holding a visitor while we try again.
27
+ DEFAULT_TIMEOUT = 2.5
28
+ DEFAULT_RETRIES = 0
29
+
30
+ # Resolve, classify, decide.
31
+ class Core
32
+ # @param default_ip_selector [#call] the framework's own accessor, used
33
+ # when the caller named none.
34
+ def initialize(default_ip_selector, **options)
35
+ Condition.validate!(options[:block_condition])
36
+ @condition = options[:block_condition]
37
+ @selector = options[:ip_selector] || default_ip_selector
38
+ @fail_closed = options.fetch(:fail_closed, false)
39
+ @on_missing_field = options.fetch(:on_missing_field, :warn)
40
+ @skip = options[:skip]
41
+ @on_warn = options[:on_warn]
42
+ @retries = options.fetch(:retries, DEFAULT_RETRIES)
43
+ Retries.checked_count(@retries) unless @retries.nil?
44
+ @warned = {}
45
+ @client = options[:client] || Client.new(
46
+ api_key: options[:api_key],
47
+ **{ base_url: options[:base_url] }.compact,
48
+ timeout: options.fetch(:timeout, DEFAULT_TIMEOUT)
49
+ )
50
+ end
51
+
52
+ # Whether a condition was configured at all.
53
+ def blocking?
54
+ !@condition.nil?
55
+ end
56
+
57
+ # Classify one request. Answers nil when `skip` claimed it.
58
+ #
59
+ # A failed LOOKUP is not raised: it lands on `Lookup#error` and the
60
+ # request is let through. What CAN raise is a misconfiguration - a
61
+ # condition naming a member the plan does not serve, with
62
+ # `on_missing_field: :raise`.
63
+ def evaluate(request)
64
+ return nil if @skip&.call(request)
65
+
66
+ ip = @selector.call(request).to_s.strip
67
+ return unresolved if ip.empty?
68
+
69
+ if Bogon.bogon?(ip)
70
+ # Expected in local development. Anywhere else it means a proxy sits
71
+ # in front and its own address is what reached us.
72
+ warn_once(
73
+ "resolved the client address as #{ip}, which is not a public address. If this " \
74
+ 'application runs behind a proxy or load balancer, configure its trusted-proxy ' \
75
+ "setting or pass an ip_selector that reads your edge's header."
76
+ )
77
+ end
78
+
79
+ begin
80
+ result = @client.lookup(ip, retries: @retries)
81
+ rescue InternetData::Error => e
82
+ return Lookup.new(blocked: @fail_closed, ip: ip, error: e)
83
+ end
84
+ decide(ip, result)
85
+ end
86
+
87
+ private
88
+
89
+ def unresolved
90
+ warn_once(
91
+ 'could not resolve a client address from this request; pass an ip_selector that ' \
92
+ 'knows where yours comes from'
93
+ )
94
+ Lookup.new(
95
+ blocked: @fail_closed,
96
+ error: InternetData::Error.new(:bad_request, 'no client address on the request')
97
+ )
98
+ end
99
+
100
+ def decide(ip, result)
101
+ return Lookup.new(blocked: false, ip: ip, result: result) if @condition.nil?
102
+
103
+ report_missing(result)
104
+ Lookup.new(
105
+ blocked: Condition.matches?(@condition, result),
106
+ ip: ip,
107
+ result: result
108
+ )
109
+ end
110
+
111
+ def report_missing(result)
112
+ return if @on_missing_field == :ignore
113
+
114
+ missing = Condition.missing_members(@condition, result)
115
+ return if missing.empty?
116
+
117
+ message = "block_condition names #{missing.join(', ')}, which your plan does not " \
118
+ 'include, so those terms can never match. An absent member means "not in ' \
119
+ 'your plan", not "checked, and no".'
120
+ raise ArgumentError, "internetdata: #{message}" if @on_missing_field == :raise
121
+
122
+ warn_once(message)
123
+ end
124
+
125
+ # A misconfiguration is the same on every request, so saying so once is a
126
+ # warning and saying so a million times is an outage of its own.
127
+ def warn_once(message)
128
+ return if @warned[message]
129
+
130
+ @warned[message] = true
131
+ @on_warn ? @on_warn.call(message) : Kernel.warn("[internetdata] #{message}")
132
+ end
133
+ end
134
+
135
+ # The shared client-address selectors, bound to one framework's request type.
136
+ #
137
+ # There is no portable default: a framework's own accessor may return the
138
+ # socket peer, or may already have walked a proxy chain, depending on the
139
+ # framework and on how the application configured it.
140
+ class Selectors
141
+ def initialize(&view)
142
+ @view = view
143
+ end
144
+
145
+ # The framework's own client-address accessor.
146
+ def default
147
+ ->(request) { @view.call(request).framework_ip.call }
148
+ end
149
+
150
+ # An address from `X-Forwarded-For`.
151
+ #
152
+ # The LEFT-MOST entry (depth 0) is whatever the caller sent, because
153
+ # proxies append to this header, so a visitor who sets it themselves
154
+ # appears first and this returns their forgery. It is only trustworthy
155
+ # when an edge you control overwrites the header. When you know how many
156
+ # proxies sit in front, count from the right: depth 1 is the address your
157
+ # nearest proxy saw.
158
+ def xff(depth = 0)
159
+ lambda do |request|
160
+ seen = @view.call(request)
161
+ chain = (seen.header.call('X-Forwarded-For') || '').split(',').map(&:strip).reject(&:empty?)
162
+ next seen.framework_ip.call if chain.empty?
163
+ next chain.first if depth <= 0 || depth > chain.length
164
+
165
+ chain[-depth]
166
+ end
167
+ end
168
+
169
+ # An address from a single-value header your edge writes -
170
+ # `header('CF-Connecting-IP')` behind Cloudflare. Falls back to the
171
+ # framework's accessor when the header is absent.
172
+ def header(name)
173
+ lambda do |request|
174
+ seen = @view.call(request)
175
+ value = (seen.header.call(name) || '').strip
176
+ value.empty? ? seen.framework_ip.call : value
177
+ end
178
+ end
179
+ end
180
+ end
181
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'middleware/condition'
4
+ require_relative 'middleware/core'
@@ -111,64 +111,44 @@ module InternetData
111
111
 
112
112
  if attributes.key?(:'verified')
113
113
  self.verified = attributes[:'verified']
114
- else
115
- self.verified = nil
116
114
  end
117
115
 
118
116
  if attributes.key?(:'id_matches_ip')
119
117
  self.id_matches_ip = attributes[:'id_matches_ip']
120
- else
121
- self.id_matches_ip = nil
122
118
  end
123
119
 
124
120
  if attributes.key?(:'first_seen')
125
121
  self.first_seen = attributes[:'first_seen']
126
- else
127
- self.first_seen = nil
128
122
  end
129
123
 
130
124
  if attributes.key?(:'last_seen')
131
125
  self.last_seen = attributes[:'last_seen']
132
- else
133
- self.last_seen = nil
134
126
  end
135
127
 
136
128
  if attributes.key?(:'last_reachable')
137
129
  self.last_reachable = attributes[:'last_reachable']
138
- else
139
- self.last_reachable = nil
140
130
  end
141
131
 
142
132
  if attributes.key?(:'days_seen')
143
133
  self.days_seen = attributes[:'days_seen']
144
- else
145
- self.days_seen = nil
146
134
  end
147
135
 
148
136
  if attributes.key?(:'num_ports')
149
137
  self.num_ports = attributes[:'num_ports']
150
- else
151
- self.num_ports = nil
152
138
  end
153
139
 
154
140
  if attributes.key?(:'peak_num_ports')
155
141
  self.peak_num_ports = attributes[:'peak_num_ports']
156
- else
157
- self.peak_num_ports = nil
158
142
  end
159
143
 
160
144
  if attributes.key?(:'indexer')
161
145
  self.indexer = attributes[:'indexer']
162
- else
163
- self.indexer = nil
164
146
  end
165
147
 
166
148
  if attributes.key?(:'clients')
167
149
  if (value = attributes[:'clients']).is_a?(Array)
168
150
  self.clients = value
169
151
  end
170
- else
171
- self.clients = nil
172
152
  end
173
153
  end
174
154
 
@@ -177,46 +157,6 @@ module InternetData
177
157
  def list_invalid_properties
178
158
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
179
159
  invalid_properties = Array.new
180
- if @verified.nil?
181
- invalid_properties.push('invalid value for "verified", verified cannot be nil.')
182
- end
183
-
184
- if @id_matches_ip.nil?
185
- invalid_properties.push('invalid value for "id_matches_ip", id_matches_ip cannot be nil.')
186
- end
187
-
188
- if @first_seen.nil?
189
- invalid_properties.push('invalid value for "first_seen", first_seen cannot be nil.')
190
- end
191
-
192
- if @last_seen.nil?
193
- invalid_properties.push('invalid value for "last_seen", last_seen cannot be nil.')
194
- end
195
-
196
- if @last_reachable.nil?
197
- invalid_properties.push('invalid value for "last_reachable", last_reachable cannot be nil.')
198
- end
199
-
200
- if @days_seen.nil?
201
- invalid_properties.push('invalid value for "days_seen", days_seen cannot be nil.')
202
- end
203
-
204
- if @num_ports.nil?
205
- invalid_properties.push('invalid value for "num_ports", num_ports cannot be nil.')
206
- end
207
-
208
- if @peak_num_ports.nil?
209
- invalid_properties.push('invalid value for "peak_num_ports", peak_num_ports cannot be nil.')
210
- end
211
-
212
- if @indexer.nil?
213
- invalid_properties.push('invalid value for "indexer", indexer cannot be nil.')
214
- end
215
-
216
- if @clients.nil?
217
- invalid_properties.push('invalid value for "clients", clients cannot be nil.')
218
- end
219
-
220
160
  invalid_properties
221
161
  end
222
162
 
@@ -224,119 +164,9 @@ module InternetData
224
164
  # @return true if the model is valid
225
165
  def valid?
226
166
  warn '[DEPRECATED] the `valid?` method is obsolete'
227
- return false if @verified.nil?
228
- return false if @id_matches_ip.nil?
229
- return false if @first_seen.nil?
230
- return false if @last_seen.nil?
231
- return false if @last_reachable.nil?
232
- return false if @days_seen.nil?
233
- return false if @num_ports.nil?
234
- return false if @peak_num_ports.nil?
235
- return false if @indexer.nil?
236
- return false if @clients.nil?
237
167
  true
238
168
  end
239
169
 
240
- # Custom attribute writer method with validation
241
- # @param [Object] verified Value to be assigned
242
- def verified=(verified)
243
- if verified.nil?
244
- fail ArgumentError, 'verified cannot be nil'
245
- end
246
-
247
- @verified = verified
248
- end
249
-
250
- # Custom attribute writer method with validation
251
- # @param [Object] id_matches_ip Value to be assigned
252
- def id_matches_ip=(id_matches_ip)
253
- if id_matches_ip.nil?
254
- fail ArgumentError, 'id_matches_ip cannot be nil'
255
- end
256
-
257
- @id_matches_ip = id_matches_ip
258
- end
259
-
260
- # Custom attribute writer method with validation
261
- # @param [Object] first_seen Value to be assigned
262
- def first_seen=(first_seen)
263
- if first_seen.nil?
264
- fail ArgumentError, 'first_seen cannot be nil'
265
- end
266
-
267
- @first_seen = first_seen
268
- end
269
-
270
- # Custom attribute writer method with validation
271
- # @param [Object] last_seen Value to be assigned
272
- def last_seen=(last_seen)
273
- if last_seen.nil?
274
- fail ArgumentError, 'last_seen cannot be nil'
275
- end
276
-
277
- @last_seen = last_seen
278
- end
279
-
280
- # Custom attribute writer method with validation
281
- # @param [Object] last_reachable Value to be assigned
282
- def last_reachable=(last_reachable)
283
- if last_reachable.nil?
284
- fail ArgumentError, 'last_reachable cannot be nil'
285
- end
286
-
287
- @last_reachable = last_reachable
288
- end
289
-
290
- # Custom attribute writer method with validation
291
- # @param [Object] days_seen Value to be assigned
292
- def days_seen=(days_seen)
293
- if days_seen.nil?
294
- fail ArgumentError, 'days_seen cannot be nil'
295
- end
296
-
297
- @days_seen = days_seen
298
- end
299
-
300
- # Custom attribute writer method with validation
301
- # @param [Object] num_ports Value to be assigned
302
- def num_ports=(num_ports)
303
- if num_ports.nil?
304
- fail ArgumentError, 'num_ports cannot be nil'
305
- end
306
-
307
- @num_ports = num_ports
308
- end
309
-
310
- # Custom attribute writer method with validation
311
- # @param [Object] peak_num_ports Value to be assigned
312
- def peak_num_ports=(peak_num_ports)
313
- if peak_num_ports.nil?
314
- fail ArgumentError, 'peak_num_ports cannot be nil'
315
- end
316
-
317
- @peak_num_ports = peak_num_ports
318
- end
319
-
320
- # Custom attribute writer method with validation
321
- # @param [Object] indexer Value to be assigned
322
- def indexer=(indexer)
323
- if indexer.nil?
324
- fail ArgumentError, 'indexer cannot be nil'
325
- end
326
-
327
- @indexer = indexer
328
- end
329
-
330
- # Custom attribute writer method with validation
331
- # @param [Object] clients Value to be assigned
332
- def clients=(clients)
333
- if clients.nil?
334
- fail ArgumentError, 'clients cannot be nil'
335
- end
336
-
337
- @clients = clients
338
- end
339
-
340
170
  # Checks equality by comparing each attribute.
341
171
  # @param [Object] Object to be compared
342
172
  def ==(o)