-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from aristotelesbr/development
refactor: remove ApplicationBase classs and improve performance on response
- Loading branch information
Showing
9 changed files
with
198 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ruby 3.3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# frozen_string_literal: true | ||
|
||
# Released under the MIT License. | ||
# Copyright, 2023-2024, by Aristóteles Coutinho. | ||
|
||
class Lennarb | ||
# This module must be included in the class that will use the router. | ||
# | ||
module Router | ||
def self.included(base) | ||
base.extend(ClassMethods) | ||
base.instance_variable_set(:@router, Lennarb.new) | ||
base.define_singleton_method(:router) do | ||
base.instance_variable_get(:@router) | ||
end | ||
end | ||
|
||
module ClassMethods | ||
# Helper method to define a route | ||
# | ||
# returns [Lennarb] instance of the router | ||
# | ||
def route = router | ||
|
||
# Use this in congi.ru to start the application | ||
# | ||
def app | ||
router.freeze! | ||
router | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
# Released under the MIT License. | ||
# Copyright, 2023-2024, by Aristóteles Coutinho. | ||
|
||
require 'test_helper' | ||
|
||
class Lennarb | ||
class TestRouterTest < Minitest::Test | ||
class MyApp | ||
include Lennarb::Router | ||
end | ||
|
||
def test_included | ||
assert_respond_to MyApp, :route | ||
assert_respond_to MyApp, :app | ||
end | ||
|
||
def test_ancestors | ||
assert_includes MyApp.ancestors, Lennarb::Router | ||
end | ||
|
||
def test_router | ||
assert_kind_of Lennarb, MyApp.router | ||
end | ||
|
||
def test_app | ||
assert_kind_of Lennarb, MyApp.app | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters