psu-libraries/psulib_blacklight

View on GitHub
app/components/browse/prefix_selector.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
# frozen_string_literal: true

module Browse
  class PrefixSelector < ViewComponent::Base
    include Paths

    attr_reader :prefix

    def initialize(prefix:)
      @prefix = prefix
    end

    def clear_prefix_path
      browse_path(merge_params)
    end

    def prefix_path(letter)
      browse_path(merge_params(prefix: letter))
    end

    private

      def merge_params(opts = {})
        params.slice(:length).merge(opts)
      end
  end
end