module Pluckers::Features::Base::Renaming

This module implements plucking belongs_to relationships in a recursive way.

The options used in this feature are:

* renames: A hash of the attributes/reflections/whatever that will be
  renamed. The key is the old name and the value is the new name.

Public Instance Methods

build_results() click to toggle source

In this method we get the renames and check result by result which ones must be applied

Calls superclass method
# File lib/pluckers/features/base/renaming.rb, line 39
def build_results
  super

  @renames.each do |old_name, new_name|
    @results.each do |_,result|
      if result.keys.include? old_name.to_sym
        result[new_name.to_sym] = result.delete(old_name.to_sym)
      end
    end
  end

end
configure_query() click to toggle source

Here we obtain the renames enabled for this plucker

Calls superclass method
# File lib/pluckers/features/base/renaming.rb, line 27
def configure_query
  super

  @renames = @options.delete(:renames)
  @renames ||= {}
  @renames = @renames.with_indifferent_access

end