tramway 1.1.0.1 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f54ede43d505864a0ef09daa5b78f0a3962546a1747426910baebbc6f8ed027
4
- data.tar.gz: 168655d5be3c9b41ae3a84ed230eb602aa4b1f9b12023c6f4990115c5aabf8ce
3
+ metadata.gz: 8b6d840374d36240b9717e7c5ef9a384e787d67e2db63be0e7794595f22619a2
4
+ data.tar.gz: 8a7af59ab9d83997530abe96d4b8b40119e2fcb90fdfbaddda9b8a0474678c94
5
5
  SHA512:
6
- metadata.gz: b665969d8d35eed72b9350146c99068aceea96b4bcf2aa0384ac90ab63622ec1c5ae941a0781af958f525a51b46e3c7c1244fc33adf45b577dfbe98f4f40076f
7
- data.tar.gz: e9c87a95e5d00a82dae672c25bfc0339f95aa1f4c56eebd6c9eea28b065f7d883dd3639cdd9079e0fa5ff698e1452349a3851ccf6be4ec5375d084dcf1a9d5aa
6
+ metadata.gz: e131ffdbeaea9be23a9b6db5995b6177b9986bc5fd808373c259afdf9be18486dbb236cd8370908ef66510858556582d5db8909f546c79e7f08e4bf2b4ea2e48
7
+ data.tar.gz: 4093f089eb5f0e8157bfe7bcedf6c34061d88af9e37a2c889d88549a6b429cb67734eb1fe6ab457c8741450b74accfc2338c215ea2a6f7b5f2d8f07d7ef3d7d5
@@ -1,5 +1,7 @@
1
1
  - decorator = Tramway::Decorators::ClassHelper.decorator_class_name(@model_class, @namespace)
2
2
  - index_attributes = decorator.constantize.index_attributes
3
+ - custom_path_method = "#{@model_class.model_name.plural}_path"
4
+ - custom_path_method = "#{@entity.namespace.gsub('/', '_')}_#{custom_path_method}" if @entity.namespace.present?
3
5
 
4
6
  .mt-8.w-full
5
7
  - content_for :title, page_title
@@ -9,7 +11,7 @@
9
11
  = content_for(:title)
10
12
 
11
13
  - if Tramway.config.pagination[:enabled]
12
- = paginate @entities, custom_path_method: "#{@model_class.model_name.plural}_path"
14
+ = paginate @entities, custom_path_method:
13
15
  .flex.justify-end.mt-2
14
16
  = decorator.constantize.index_header_content.call(@entities) if decorator.constantize.index_header_content.present?
15
17
 
@@ -25,4 +27,4 @@
25
27
 
26
28
  - if Tramway.config.pagination[:enabled]
27
29
  .flex.mt-4
28
- = paginate @entities, custom_path_method: "#{@model_class.model_name.plural}_path"
30
+ = paginate @entities, custom_path_method:
data/config/routes.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'tramway/helpers/routes_helper'
4
+
3
5
  # rubocop:disable Metrics/BlockLength
4
6
  Tramway::Engine.routes.draw do
5
7
  Tramway.config.entities.each do |entity|
@@ -41,3 +43,9 @@ Tramway::Engine.routes.draw do
41
43
  end
42
44
  end
43
45
  # rubocop:enable Metrics/BlockLength
46
+
47
+ Tramway::Engine.routes.routes.map(&:name).compact.each do |route_name|
48
+ %w[path url].each do |suffix|
49
+ Tramway::Helpers::RoutesHelper.define_route_helper("#{route_name}_#{suffix}")
50
+ end
51
+ end
@@ -11,6 +11,7 @@ module Tramway
11
11
  load_views_helper
12
12
  load_decorator_helper
13
13
  load_form_helper
14
+ load_routes_helper
14
15
  configure_pagination if Tramway.config.pagination[:enabled]
15
16
  end
16
17
 
@@ -52,8 +53,20 @@ module Tramway
52
53
  end
53
54
  end
54
55
 
55
- # :reek:NestedIterators { enabled: false }
56
- # :reek:TooManyStatements { enabled: false }
56
+ def load_routes_helper
57
+ ActiveSupport.on_load(:action_controller) do |loaded_class|
58
+ require 'tramway/helpers/routes_helper'
59
+
60
+ loaded_class.include Tramway::Helpers::RoutesHelper
61
+ end
62
+
63
+ ActiveSupport.on_load(:action_view) do |loaded_class|
64
+ require 'tramway/helpers/routes_helper'
65
+
66
+ loaded_class.include Tramway::Helpers::RoutesHelper
67
+ end
68
+ end
69
+
57
70
  def configure_pagination
58
71
  ActiveSupport.on_load(:action_controller) do
59
72
  # Detecting tramway views path
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tramway
4
+ module Helpers
5
+ # Provides shortcut helpers that delegate to Tramway engine routes
6
+ module RoutesHelper
7
+ class << self
8
+ def define_route_helper(method_name)
9
+ define_method(method_name) do |*args, **kwargs, &block|
10
+ Tramway::Engine.routes.url_helpers.public_send(method_name, *args, **kwargs, &block)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tramway
4
- VERSION = '1.1.0.1'
4
+ VERSION = '1.1.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tramway
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0.1
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - kalashnikovisme
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2025-11-25 00:00:00.000000000 Z
12
+ date: 2025-11-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: anyway_config
@@ -250,6 +250,7 @@ files:
250
250
  - lib/tramway/helpers/decorate_helper.rb
251
251
  - lib/tramway/helpers/form_helper.rb
252
252
  - lib/tramway/helpers/navbar_helper.rb
253
+ - lib/tramway/helpers/routes_helper.rb
253
254
  - lib/tramway/helpers/views_helper.rb
254
255
  - lib/tramway/navbar.rb
255
256
  - lib/tramway/utils/render.rb