spree/spree — pull request #4739 by lailsonbm (2014-05-25 14:21:04+00:00)
Title: Makes taxonomies API more extensible

Makes small changes to the taxonomies API controller so it is easier to extend it via a decorator.

For example, consider the case where someone wants to restrict the taxonomies with a scope. Before this change, the only way to do it was overwrite the index action and duplicate the internal spree code (note the call to `my_scope` in the end of the chain):

```ruby
Spree::Api::TaxonomiesController.class_eval do
def index
@taxonomies = Taxonomy.accessible_by(current_ability, :read).order('name').includes(:root => :children).
ransack(params[:q]).result.
page(params[:page]).per(params[:per_page]).my_scope
respond_with(@taxonomies)
end
end
```

But after the change, we can just append the scope and avoid duplication:

```ruby
Spree::Api::TaxonomiesController.class_eval do
private

alias_method :original_taxonomies, :taxonomies
def taxonomies
original_taxonomies.my_scope
end
end
```

The same arguments holds for the show action.

Since no new functionality was introduced, I didn't added tests.