diff --git a/CHANGELOG.md b/CHANGELOG.md index b3fc04b..8ccbc86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.1.5] - 2023-25-11 + +### Added + +- Add `assign_params` method to Request class + ## [0.1.4] - 2023-25-11 ### Fixed diff --git a/Gemfile.lock b/Gemfile.lock index e8268c7..749c6d1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - lennarb (0.1.4) + lennarb (0.1.5) colorize (~> 1.1) puma (~> 6.4) rack (~> 3.0, >= 3.0.8) diff --git a/lib/lenna/router/request.rb b/lib/lenna/router/request.rb index b34a03f..d1cd552 100644 --- a/lib/lenna/router/request.rb +++ b/lib/lenna/router/request.rb @@ -8,6 +8,16 @@ class Router # @attr body [Hash] the request body # @attr params [Hash] the request params class Request < ::Rack::Request + + # This method is used to set the request params. + # + # @param params [Hash] the request params + # + # @return [Hash] the request params + # + # @api public + def assign_params(params) = @params = params + # This method is used to parse the body params. # # @return [Hash] the request params diff --git a/lib/lennarb/version.rb b/lib/lennarb/version.rb index ce700ff..cab8303 100644 --- a/lib/lennarb/version.rb +++ b/lib/lennarb/version.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Lennarb - VERSION = '0.1.4' + VERSION = '0.1.5' public_constant :VERSION end diff --git a/test/lib/lenna/router/test_request.rb b/test/lib/lenna/router/test_request.rb index 83eb854..531b62c 100644 --- a/test/lib/lenna/router/test_request.rb +++ b/test/lib/lenna/router/test_request.rb @@ -5,6 +5,15 @@ module Lenna class Router class TestRequest < Minitest::Test + def test_assing_params + env = ::Rack::MockRequest.env_for('/', method: 'POST') + request = Request.new(env) + + request.assign_params({ 'foo' => 'bar' }) + + assert_equal({ 'foo' => 'bar' }, request.params) + end + def test_with_query_string env = ::Rack::MockRequest.env_for('/?foo=bar')