# Rubanok

> A magical Ruby DSL for transforming params in HTTP controllers.

- URL: https://evilmartians.com/opensource/rubanok
- GitHub: https://github.com/palkan/rubanok
- Authors: Vladimir Dementyev

---

Rubanok is a magical Ruby DSL for transforming params in HTTP controllers.

The typical usage is to describe all the possible collection manipulation for REST `index` action, e.g. filtering, sorting, searching, pagination, etc..

So, instead of:

```ruby
class CourseSessionController < ApplicationController
  def index
    @sessions = CourseSession
      .search(params[:q])
      .by_course_type(params[:course_type_id])
      .by_role(params[:role_id])
      .paginate(page_params)
      .order(ordering_params)
  end
end
```

You have:

```ruby
class CourseSessionController < ApplicationController
  def index
    @sessions = rubanok_process(
      # pass input
      CourseSession.all,
      # pass params
      params,
      # provide a processor to use
      with: CourseSessionsProcessor
    )
  end
end
```

Or we can try to infer all the configuration for you:

```ruby
class CourseSessionController < ApplicationController
  def index
    @sessions = rubanok_process(CourseSession.all)
  end
end
```
