Class: ArelConverter::Translator::Association
- Defined in:
- lib/arel_converter/translators/association.rb
Constant Summary
Constants inherited from Base
Instance Method Summary collapse
- #post_processing(new_scope) ⇒ Object
- #process_call(exp) ⇒ Object
-
#process_hash(exp) ⇒ Object
:nodoc:.
Methods inherited from Base
#format_for_hash, #logger, parse, translate
Instance Method Details
#post_processing(new_scope) ⇒ Object
33 34 35 36 37 |
# File 'lib/arel_converter/translators/association.rb', line 33 def post_processing(new_scope) new_scope.gsub!(/has_(many|one|and_belongs_to_many)\((.*)\)$/, 'has_\1 \2') new_scope.gsub!(/belongs_to\((.*)\)$/, 'belongs_to \1') [new_scope, format_scope(@scopes), @options].compact.join(', ') end |
#process_call(exp) ⇒ Object
5 6 7 8 |
# File 'lib/arel_converter/translators/association.rb', line 5 def process_call(exp) @association_type ||= exp[1] super end |
#process_hash(exp) ⇒ Object
:nodoc:
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/arel_converter/translators/association.rb', line 10 def process_hash(exp) # :nodoc: @options = [] scopes = [:hash] until exp.empty? lhs = exp.shift rhs = exp.shift if option_nodes.include?(lhs) lhs = process(lhs) t = rhs.first rhs = process rhs rhs = "(#{rhs})" unless [:lit, :str, :true, :false].include? t # TODO: verify better! @options << format_for_hash(lhs,rhs) else scopes += [lhs, rhs] end end @options = nil if @options.empty? @scopes = Options.translate(Sexp.from_array(scopes)) unless scopes == [:hash] return '' end |