Class: Arspy::Operators::Selector::HashSelector
- Inherits:
-
Base
- Object
- Base
- Arspy::Operators::Selector::HashSelector
show all
- Defined in:
- lib/arspy/operators/selector/hash_selector.rb
Constant Summary
collapse
- @@hash_selector_classes =
[
Selector::AttributeSelector,
Selector::UnsupportedSelector
]
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Class Method Details
.applies?(arg) ⇒ Boolean
10
11
12
|
# File 'lib/arspy/operators/selector/hash_selector.rb', line 10
def self.applies?(arg)
arg.is_a? Hash
end
|
Instance Method Details
#hash_selector_class_for(key_value) ⇒ Object
23
24
25
|
# File 'lib/arspy/operators/selector/hash_selector.rb', line 23
def hash_selector_class_for(key_value)
@@hash_selector_classes.detect{|klass| klass.applies?(key_value) }
end
|
#select?(obj) ⇒ Boolean
14
15
16
|
# File 'lib/arspy/operators/selector/hash_selector.rb', line 14
def select?(obj)
selectors.any?{|selector| selector.select?(obj) }
end
|
#selectors ⇒ Object
18
19
20
21
22
|
# File 'lib/arspy/operators/selector/hash_selector.rb', line 18
def selectors
@selectors ||= @argument.map do |key_value|
hash_selector_class_for(key_value).new(key_value)
end
end
|