Class: Rails::Surrender::FilterBuilder
- Inherits:
-
Object
- Object
- Rails::Surrender::FilterBuilder
- Defined in:
- lib/rails/surrender/helpers/filter_builder.rb
Overview
apply filtering directives to the given resource, based on the given filter controls
Instance Attribute Summary collapse
-
#filter ⇒ Object
readonly
Returns the value of attribute filter.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Instance Method Summary collapse
- #build! ⇒ Object
-
#initialize(resource:, filter:) ⇒ FilterBuilder
constructor
A new instance of FilterBuilder.
Constructor Details
#initialize(resource:, filter:) ⇒ FilterBuilder
Returns a new instance of FilterBuilder.
9 10 11 12 |
# File 'lib/rails/surrender/helpers/filter_builder.rb', line 9 def initialize(resource:, filter:) @resource = resource @filter = filter end |
Instance Attribute Details
#filter ⇒ Object (readonly)
Returns the value of attribute filter.
7 8 9 |
# File 'lib/rails/surrender/helpers/filter_builder.rb', line 7 def filter @filter end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
7 8 9 |
# File 'lib/rails/surrender/helpers/filter_builder.rb', line 7 def resource @resource end |
Instance Method Details
#build! ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rails/surrender/helpers/filter_builder.rb', line 14 def build! return resource unless resource.is_a?(ActiveRecord::Relation) filter.each do |term| scope, value = term.first send_filter_for(scope, value) end resource end |