Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add assign_params to Reques class #12

Merged
merged 4 commits into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
10 changes: 10 additions & 0 deletions lib/lenna/router/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/lennarb/version.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Lennarb
VERSION = '0.1.4'
VERSION = '0.1.5'

public_constant :VERSION
end
9 changes: 9 additions & 0 deletions test/lib/lenna/router/test_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down