Sha256: cc1baaea34eb87d46bf12cee7b134643d7f910c130b3ee6080d3c4d72fd86dc8

Contents?: true

Size: 1.62 KB

Versions: 14

Compression:

Stored size: 1.62 KB

Contents

class PeakFlowUtils::WillPaginateHandler < PeakFlowUtils::ApplicationHandler
  def enabled?
    ::Object.const_defined?(:WillPaginate)
  end

  def groups
    ArrayEnumerator.new do |yielder|
      groups = ["will_paginate"]

      groups.each do |group|
        yielder << PeakFlowUtils::GroupService.new(
          id: group,
          handler: self,
          data: {
            name: group.humanize
          }
        )
      end
    end
  end

  def translations_for_group(group)
    ArrayEnumerator.new do |yielder|
      dir = Rails.root.join("config", "locales", "awesome_translations", group.id).to_s
      __send__("translations_for_#{group.id}", dir, group, yielder)
    end
  end

private

  def translations_for_will_paginate(dir, group, yielder)
    add_translations_for_hash(
      dir,
      group,
      yielder,
      translations: {
        will_paginate: {
          previous_label: "&#8592; Previous",
          next_label: "Next &#8594;",
          page_gap: "&hellip;",
          page_entries_info: {
            single_page: {
              zero: "No %{model} found",
              one: "Displaying 1 %{model}",
              other: "Displaying all %{count} %{model}"
            },
            single_page_html: {
              zero: "No %{model} found",
              one: "Displaying <b>1</b> %{model}",
              other: "Displaying <b>all&nbsp;%{count}</b> %{model}"
            },
            multi_page: "Displaying %{model} %{from} - %{to} of %{count} in total",
            multi_page_html: "Displaying %{model} <b>%{from}&nbsp;-&nbsp;%{to}</b> of <b>%{count}</b> in total"
          }
        }
      }
    )
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
peak_flow_utils-0.1.19 app/handlers/peak_flow_utils/will_paginate_handler.rb
peak_flow_utils-0.1.18 app/handlers/peak_flow_utils/will_paginate_handler.rb
peak_flow_utils-0.1.17 app/handlers/peak_flow_utils/will_paginate_handler.rb
peak_flow_utils-0.1.16 app/handlers/peak_flow_utils/will_paginate_handler.rb
peak_flow_utils-0.1.15 app/handlers/peak_flow_utils/will_paginate_handler.rb
peak_flow_utils-0.1.14 app/handlers/peak_flow_utils/will_paginate_handler.rb
peak_flow_utils-0.1.13 app/handlers/peak_flow_utils/will_paginate_handler.rb
peak_flow_utils-0.1.12 app/handlers/peak_flow_utils/will_paginate_handler.rb
peak_flow_utils-0.1.11 app/handlers/peak_flow_utils/will_paginate_handler.rb
peak_flow_utils-0.1.10 app/handlers/peak_flow_utils/will_paginate_handler.rb
peak_flow_utils-0.1.9 app/handlers/peak_flow_utils/will_paginate_handler.rb
peak_flow_utils-0.1.8 app/handlers/peak_flow_utils/will_paginate_handler.rb
peak_flow_utils-0.1.7 app/handlers/peak_flow_utils/will_paginate_handler.rb
peak_flow_utils-0.1.6 app/handlers/peak_flow_utils/will_paginate_handler.rb