Module: Arspy::Operators::Interpreter

Defined in:
lib/arspy/operators/interpreter.rb,
lib/arspy/operators/interpreter/base.rb,
lib/arspy/operators/interpreter/null_interpreter.rb,
lib/arspy/operators/interpreter/method_interpreter.rb,
lib/arspy/operators/interpreter/attribute_interpreter.rb,
lib/arspy/operators/interpreter/association_interpreter.rb,
lib/arspy/operators/interpreter/abbreviated_attribute_interpreter.rb,
lib/arspy/operators/interpreter/abbreviated_association_interpreter.rb

Defined Under Namespace

Classes: AbbreviatedAssociationInterpreter, AbbreviatedAttributeInterpreter, AssociationInterpreter, AttributeInterpreter, Base, MethodInterpreter, NullInterpreter

Constant Summary collapse

@@interpreter_classes =
[
  AssociationInterpreter, AttributeInterpreter,
  MethodInterpreter, AbbreviatedAssociationInterpreter,
  AbbreviatedAttributeInterpreter,
  NullInterpreter
]
@@abbreviations_enabled =
true

Class Method Summary collapse

Class Method Details

.for(array, method_name) ⇒ Object



20
21
22
23
# File 'lib/arspy/operators/interpreter.rb', line 20

def self.for(array, method_name)
  return NullInterpreter.new(array, method_name) unless (array && method_name && array.is_a?(Array) && !array.empty? && array.first.is_a?(ActiveRecord::Base))
  @@interpreter_classes.detect{|klass| klass.applies?(array, method_name)}.new(array, method_name)
end