auto_breadcrumbs 0.3.0 → 0.3.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
  SHA1:
3
- metadata.gz: 49f9086b4ad4960dddcca1e29c99977bf0f5fdcc
4
- data.tar.gz: 77084a18e6d528247d1ac4a8bc57886f2426cef7
3
+ metadata.gz: b25c6416df01b8c1893082a7fdd50a79f1b97f6e
4
+ data.tar.gz: 5ea2e2a03603fecf4a1a432268c718dc52a4a1f0
5
5
  SHA512:
6
- metadata.gz: 9ff92bed3f963ce8c7cd33c2c632091eaa55aa7b56d499d11bc0ca697f792cbbfb25aa7a3452c2c19d05cd6f70a4c34963ae615a261faa494d6542ae1577f22a
7
- data.tar.gz: a1e94c04dfc5c42eb1b87571c2c5ebc2314c6ae2ee983689bfc5516e09d3c85b52803bf9c052fb009aa413fd1dd2f111c792757887db0fffd735925ccdfc9a32
6
+ metadata.gz: a267e25a24b773f93e0a74f2f3f455c22a58fb0ff3573cbca8cdaa9ab9882c300e96dfbe98f35a323f40447327ccb71520f385ef96e6cd8e26d0100c150e8978
7
+ data.tar.gz: 532e84006f150710d765b5a3ba57649ed266a6fe7e9dfcc4aa2bee8ef0a25a295d2bc4c8c8354263b637c3e6523d93708ae7a9aac441577df222cc6edc441f91
@@ -20,33 +20,35 @@ module AutoBreadcrumbs
20
20
  # nested resources
21
21
  Rails.application.routes.router.recognize(request) do |route, matches, param|
22
22
  route.required_parts[0...-1].each do |required_part|
23
- resources_name = required_part.to_s.gsub('_id', '').pluralize
24
- resource_translation = resource_translation(resources_name)
25
- resource_index_path = index_path(resources_name)
26
- action_translation = action_translation(resources_name, 'show')
23
+ resources_name = required_part.to_s.gsub('_id', '').pluralize
24
+ resource_index_path = index_path(resources_name)
25
+ nested_resource_translation = resource_translation(resources_name)
26
+ nested_action_translation = action_translation(resources_name, 'show')
27
27
 
28
- add_breadcrumb(resource_translation, resource_index_path) if resource_translation
29
- add_breadcrumb(action_translation) if action_translation
28
+ add_breadcrumb(nested_resource_translation, resource_index_path) if nested_resource_translation
29
+ add_breadcrumb(nested_action_translation) if nested_action_translation
30
30
  end
31
31
  end
32
32
 
33
- resource_translation = resource_translation(params[:controller])
34
- resource_index_path = index_path(params[:controller])
35
- action_translation = action_translation(params[:controller], params[:action])
36
-
33
+ resource_index_path = index_path(params[:controller])
37
34
  add_breadcrumb(resource_translation, resource_index_path) if resource_translation
38
35
  add_breadcrumb(action_translation) if action_translation
39
36
  end
40
37
  end
41
38
 
42
- def resource_translation(resources_name)
39
+ def resource_translation(resources_name = nil)
40
+ resources_name ||= params[:controller]
41
+
43
42
  if index_path(resources_name)
44
43
  breadcrumbs_t("controllers.#{ resources_name }.index") ||
45
44
  resources_name.humanize
46
45
  end
47
46
  end
48
47
 
49
- def action_translation(resources_name, action_name)
48
+ def action_translation(resources_name = nil, action_name = nil)
49
+ resources_name ||= params[:controller]
50
+ action_name ||= params[:action]
51
+
50
52
  mapped_action_name = breadcrumbs_action_name(action_name)
51
53
 
52
54
  unless mapped_action_name == 'index'
@@ -1,3 +1,3 @@
1
1
  module AutoBreadcrumbs
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auto_breadcrumbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeny Li