Sha256: 9e940a94450a8749c3f7b4c6d8976084a38618793aec1afd4d72129f6e7dd4dd

Contents?: true

Size: 830 Bytes

Versions: 19

Compression:

Stored size: 830 Bytes

Contents

module Headmin
  module RequestHelper
    def current_url?(url)
      uri = URI(url)
      path = uri.path
      query_string = uri.query || ""
      matches_path = request.path.include?(path)
      matches_query = request.query_string.include?(query_string)
      matches_path && matches_query
    end

    def default_params
      params.select { |key, value| is_default_param?(key) }
    end

    def add_default_param_key(key)
      keys = default_param_keys || []
      keys.push(key)
      @default_param_keys = keys
    end

    def default_param_keys
      @default_param_keys ||= [:page, :start, :length, :per_page]
    end

    def is_default_param?(key)
      default_param_keys.include?(key.to_sym) || is_sort_param_key?(key)
    end

    def is_sort_param_key?(key)
      key.to_s.include?("sort_")
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
headmin-0.6.3 app/helpers/headmin/request_helper.rb
headmin-0.6.2 app/helpers/headmin/request_helper.rb
headmin-0.6.1 app/helpers/headmin/request_helper.rb
headmin-0.6.0 app/helpers/headmin/request_helper.rb
headmin-0.5.9 app/helpers/headmin/request_helper.rb
headmin-0.5.8 app/helpers/headmin/request_helper.rb
headmin-0.5.7 app/helpers/headmin/request_helper.rb
headmin-0.5.6 app/helpers/headmin/request_helper.rb
headmin-0.5.5 app/helpers/headmin/request_helper.rb
headmin-0.5.4 app/helpers/headmin/request_helper.rb
headmin-0.5.3 app/helpers/headmin/request_helper.rb
headmin-0.5.2 app/helpers/headmin/request_helper.rb
headmin-0.5.1 app/helpers/headmin/request_helper.rb
headmin-0.5.0 app/helpers/headmin/request_helper.rb
headmin-0.4.2 app/helpers/headmin/request_helper.rb
headmin-0.4.1 app/helpers/headmin/request_helper.rb
headmin-0.4.0 app/helpers/headmin/request_helper.rb
headmin-0.3.4 app/helpers/headmin/request_helper.rb
headmin-0.3.3 app/helpers/headmin/request_helper.rb