Class: Arspy::Operators::Interpreter::AssociationInterpreter

Inherits:
Base
  • Object
show all
Defined in:
lib/arspy/operators/interpreter/association_interpreter.rb

Direct Known Subclasses

AbbreviatedAssociationInterpreter

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Arspy::Operators::Interpreter::Base

Class Method Details

.applies?(array, method_name) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/arspy/operators/interpreter/association_interpreter.rb', line 7

def self.applies?(array, method_name)
  array.first.class.reflect_on_all_associations.detect{|a| a.name == method_name}
end

Instance Method Details

#interpret(*args) ⇒ Object



11
12
13
# File 'lib/arspy/operators/interpreter/association_interpreter.rb', line 11

def interpret(*args)
  @array.map(&@method_name).flatten
end