Sha256: ac55694a5c69ff047ca1c2e78046e8514a2ce0459022a2c471794dab54163889

Contents?: true

Size: 1.1 KB

Versions: 10

Compression:

Stored size: 1.1 KB

Contents

# Namespace for Parliament::Request helper methods.
module Parliament
  module Utils
    module Helpers
      module RequestHelper
        # Takes a Parliament::Request and calls the #get method.
        # Then maps the #value method on the resulting response.
        #
        # @param [Parliament::Request] request a built Parliament::Request object that can just be called with #get
        #
        # @return [Array<String>]
        def self.process_available_letters(request)
          response = request.get
          response.map(&:value)
        end

        # Takes a Parliament::Request and a optional amount of filters and calls the #get method on on the request.
        # Then calls Parliament::Response#filter with the filters as the parameters on the resulting response.
        #
        # @param [Parliament::Request] request a built Parliament::Request object that can just be called with #get
        #
        # @return [Parliament::Response]
        def self.filter_response_data(request, *filters)
          response = request.get
          response.filter(*filters)
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
parliament-utils-0.3.2 lib/parliament/utils/helpers/request_helper.rb
parliament-utils-0.3.1 lib/parliament/utils/helpers/request_helper.rb
parliament-utils-0.3.0 lib/parliament/utils/helpers/request_helper.rb
parliament-utils-0.2.5 lib/parliament/utils/helpers/request_helper.rb
parliament-utils-0.2.4 lib/parliament/utils/helpers/request_helper.rb
parliament-utils-0.2.3 lib/parliament/utils/helpers/request_helper.rb
parliament-utils-0.2.2 lib/parliament/utils/helpers/request_helper.rb
parliament-utils-0.2.1 lib/parliament/utils/helpers/request_helper.rb
parliament-utils-0.2.0 lib/parliament/utils/helpers/request_helper.rb
parliament-utils-0.1.0 lib/parliament/utils/helpers/request_helper.rb