module Rubanok
Rubanok
provides a DSL
to build parameters-based data transformers.
Example:
class CourseSessionProcessor < Rubanok::Processor map :q do |q:| raw.searh(q) end end class CourseSessionController < ApplicationController def index @sessions = rubanok_process(CourseSession.all) end end
Constants
- Plane
Base class for processors (planes)
Define transformation rules via `map` and `match` methods and apply them by calling the processor:
class MyTransformer < Rubanok::Processor map :type do raw.where(type: type) end end MyTransformer.call(MyModel.all, {type: "public"})
NOTE: the second argument (`params`) MUST be a Hash. Keys could be either Symbols or Strings (we automatically transform strings to symbols while matching rules).
All transformation methods are called within the context of the instance of a processor class.
You can access the input data via `raw` method.
- VERSION
Attributes
fail_when_no_matches[RW]
Define wheter to fail when `match` rule cannot find matching value
ignore_empty_values[RW]
Define whether to ignore empty values in params or not. When the value is empty and ignored the corresponding matcher/mapper is not activated (true by default)
Public Instance Methods
empty?()
click to toggle source
# File lib/rubanok/rule.rb, line 6 def empty? true end