Class: StudFinder::RailsInference
- Inherits:
-
Object
- Object
- StudFinder::RailsInference
- Defined in:
- lib/stud_finder/rails_inference.rb
Overview
Extracts conservative Rails-style implicit constant references from Ruby ASTs.
Defined Under Namespace
Classes: Inference
Constant Summary collapse
- ASSOCIATIONS =
%i[belongs_to has_one has_many has_and_belongs_to_many].freeze
- COLLECTION_ASSOCIATIONS =
%i[has_many has_and_belongs_to_many].freeze
- STRING_CONSTANTIZERS =
%i[constantize safe_constantize].freeze
- SAFE_CLASS_BODY_WRAPPERS =
%i[with_options included class_eval class_exec].freeze
- IRREGULAR_SINGULARS =
{ 'people' => 'person', 'children' => 'child', 'men' => 'man', 'women' => 'woman', 'mice' => 'mouse', 'geese' => 'goose' }.freeze
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(ast) ⇒ RailsInference
constructor
A new instance of RailsInference.
Constructor Details
#initialize(ast) ⇒ RailsInference
Returns a new instance of RailsInference.
21 22 23 |
# File 'lib/stud_finder/rails_inference.rb', line 21 def initialize(ast) @ast = ast end |
Instance Method Details
#call ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/stud_finder/rails_inference.rb', line 25 def call return [] unless @ast @ast.each_node(:send).filter_map do |node| association_inference(node) || string_constant_inference(node) end end |