class ArelConverter::Translator::Scope

Public Instance Methods

post_processing(new_scope) click to toggle source
# File lib/arel_converter/translators/scope.rb, line 10
def post_processing(new_scope)
  new_scope.gsub!(/scope\((.*)\)$/, 'scope \1')
  new_scope += format_options(@options)
end
process_call(exp) click to toggle source
Calls superclass method
# File lib/arel_converter/translators/scope.rb, line 5
def process_call(exp)
  @options = Options.translate(exp.pop) if exp[1] == :scope
  super
end

Protected Instance Methods

format_options(options) click to toggle source
# File lib/arel_converter/translators/scope.rb, line 17
def format_options(options)
  return if options.nil? || options.empty?
  ", " + (includes_lambda?(options) ? options : "-> { #{options.strip} }")
end
includes_lambda?(source) click to toggle source
# File lib/arel_converter/translators/scope.rb, line 22
def includes_lambda?(source)
  source.include?('lambda') || source.include?('->')
end