Class: KeySet
- Inherits:
-
Object
show all
- Defined in:
- lib/key_set.rb,
lib/key_set/all.rb,
lib/key_set/none.rb,
lib/key_set/some.rb,
lib/key_set/version.rb,
lib/key_set/based_on_keys.rb,
lib/key_set/all_except_some.rb
Defined Under Namespace
Modules: BasedOnKeys
Classes: All, AllExceptSome, Error, None, Some
Constant Summary
collapse
- VERSION =
'1.0.0'
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.all ⇒ Object
17
18
19
|
# File 'lib/key_set.rb', line 17
def self.all
All.new
end
|
.all_except_some(keys) ⇒ Object
31
32
33
34
35
|
# File 'lib/key_set.rb', line 31
def self.all_except_some(keys)
return all if keys.blank?
AllExceptSome.new keys
end
|
.default_logger ⇒ Object
12
13
14
15
|
# File 'lib/key_set.rb', line 12
def self.default_logger
require 'logger'
::Logger.new($stdout)
end
|
.logger ⇒ Object
8
9
10
|
# File 'lib/key_set.rb', line 8
def self.logger
@logger ||= default_logger
end
|
.none ⇒ Object
21
22
23
|
# File 'lib/key_set.rb', line 21
def self.none
None.new
end
|
.some(keys) ⇒ Object
25
26
27
28
29
|
# File 'lib/key_set.rb', line 25
def self.some(keys)
return none if keys.blank?
Some.new keys
end
|
Instance Method Details
#<=>(other) ⇒ Object
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/key_set.rb', line 75
def <=>(other)
if self.class.class_sort_index == other.class.class_sort_index
if respond_to? :keys_array
keys_array <=> other.keys_array
else
0
end
else
self.class.class_sort_index <=> other.class.class_sort_index
end
end
|
#==(other) ⇒ Object
91
92
93
|
# File 'lib/key_set.rb', line 91
def ==(other)
self.class == other.class && try(:keys_array) == other.try(:keys_array)
end
|
#===(other) ⇒ Object
87
88
89
|
# File 'lib/key_set.rb', line 87
def ===(other)
self.class == other.class && try(:keys_array) === other.try(:keys_array)
end
|
#eql?(other) ⇒ Boolean
95
96
97
|
# File 'lib/key_set.rb', line 95
def eql?(other)
self.class == other.class && try(:keys_array) == other.try(:keys_array)
end
|
#hash ⇒ Object
67
68
69
70
71
72
73
|
# File 'lib/key_set.rb', line 67
def hash
if respond_to? :keys
[self.class.to_s, keys.map(&:hash)].hash
else
self.class.to_s.hash
end
end
|
#intersect(_other) ⇒ KeySet
56
57
58
|
# File 'lib/key_set.rb', line 56
def intersect(_other)
raise NotImplementedError
end
|
61
62
63
|
# File 'lib/key_set.rb', line 61
def invert
raise NotImplementedError
end
|
#remove(_other) ⇒ KeySet
50
51
52
|
# File 'lib/key_set.rb', line 50
def remove(_other)
raise NotImplementedError
end
|
#represents_all? ⇒ Boolean
39
40
41
|
# File 'lib/key_set.rb', line 39
def represents_all?
false
end
|
#represents_none? ⇒ Boolean
43
44
45
|
# File 'lib/key_set.rb', line 43
def represents_none?
false
end
|