Class: ArelConverter::Association

Inherits:
Base
  • Object
show all
Defined in:
lib/arel_converter/association.rb

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods inherited from Base

#initialize, #parse_directory, #parse_file, #process_lines, #run!, #update_file

Constructor Details

This class inherits a constructor from ArelConverter::Base

Instance Method Details

#grep_matches_in_file(file) ⇒ Object



4
5
6
7
# File 'lib/arel_converter/association.rb', line 4

def grep_matches_in_file(file)
  raw_named_scopes = `grep -hr "^\s*has_\\|belongs_to" #{file}`
  raw_named_scopes.split("\n")
end

#process_line(line) ⇒ Object



9
10
11
# File 'lib/arel_converter/association.rb', line 9

def process_line(line)
  ArelConverter::Translator::Association.translate(line)
end

#verify_line(line) ⇒ Object



13
14
15
16
17
# File 'lib/arel_converter/association.rb', line 13

def verify_line(line)
  parser = RubyParser.new
  sexp   = parser.process(line)
  sexp.shift == :call
end