Class: Kadmin::FinderDecorator
- Inherits:
-
Object
- Object
- Kadmin::FinderDecorator
- Defined in:
- app/decorators/kadmin/finder_decorator.rb
Instance Attribute Summary collapse
-
#finder ⇒ Kadmin::Finder
readonly
Underlying finder model.
Instance Method Summary collapse
-
#applied_filters ⇒ String
A description of the current applied filters.
-
#initialize(finder) ⇒ FinderDecorator
constructor
A new instance of FinderDecorator.
-
#pager ⇒ Kadmin::PagerDecorator
Decorated pager of the underlying finder.
-
#resource_name ⇒ String
Human readable, singular/plural form of the finder's model.
Constructor Details
#initialize(finder) ⇒ FinderDecorator
Returns a new instance of FinderDecorator.
8 9 10 |
# File 'app/decorators/kadmin/finder_decorator.rb', line 8 def initialize(finder) @finder = finder end |
Instance Attribute Details
#finder ⇒ Kadmin::Finder (readonly)
Returns underlying finder model.
4 5 6 |
# File 'app/decorators/kadmin/finder_decorator.rb', line 4 def finder @finder end |
Instance Method Details
#applied_filters ⇒ String
Returns a description of the current applied filters.
18 19 20 21 22 23 24 25 26 |
# File 'app/decorators/kadmin/finder_decorator.rb', line 18 def applied_filters filters = @finder.filters.reduce([]) do |acc, (name, filter)| next(acc) if filter.value.blank? acc << %(<strong>#{filter.value}</strong> on <em>#{name}</em>).html_safe end applied_filters = "(filtering: #{filters.join('; ')})" unless filters.empty? return applied_filters end |
#pager ⇒ Kadmin::PagerDecorator
Returns decorated pager of the underlying finder.
29 30 31 |
# File 'app/decorators/kadmin/finder_decorator.rb', line 29 def pager return @pager ||= Kadmin::PagerDecorator.new(@finder.pager) end |
#resource_name ⇒ String
Returns human readable, singular/plural form of the finder's model.
13 14 15 |
# File 'app/decorators/kadmin/finder_decorator.rb', line 13 def resource_name return @finder.scope.model_name.human(count: pager.displayed_items) end |