Class: Arspy::Operators::Interpreter::AttributeInterpreter
- Inherits:
-
Base
- Object
- Base
- Arspy::Operators::Interpreter::AttributeInterpreter
show all
- Defined in:
- lib/arspy/operators/interpreter/attribute_interpreter.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Class Method Details
.applies?(array, method_name) ⇒ Boolean
6
7
8
|
# File 'lib/arspy/operators/interpreter/attribute_interpreter.rb', line 6
def self.applies?(array, method_name)
array.first.attribute_names.include?(method_name.to_s)
end
|
Instance Method Details
#interpret(*args) ⇒ Object
10
11
12
13
14
15
|
# File 'lib/arspy/operators/interpreter/attribute_interpreter.rb', line 10
def interpret(*args)
return @array.map(&@method_name) if args.empty?
raise 'Hash not supported as attribute conditionals' if args.any?{|arg| arg.is_a?(Hash)}
selector = Selector.for({@method_name => args})
@array.select{|obj| obj && selector.select?(obj)}
end
|