wallaby-view 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9f47755d845bd5adf4199a5d7e11a50788f1505fdf8c786a447252e8fa0ac29
4
- data.tar.gz: 4d953c4142e42b2341bf26c55b0d2ad84683c73f95bc526867d2091db3eb6ed1
3
+ metadata.gz: dbb2b53edfd05292aa8277741b572b703f952befd6048c4592f9f1eea60e6cb0
4
+ data.tar.gz: 57fb94ffc44a1b6cd67a9e20939c3535b74d6c5a2283237f69548551d437eb44
5
5
  SHA512:
6
- metadata.gz: 3a5e064cda03c29e6ce17b45e9b945e17bde7d9cb8c091106143624d9b997459ce015d44d07d9e0eb02d540fa05b7a307838c8208d382a021a3ea8eb45dc9ab3
7
- data.tar.gz: af47857fa027f84384740f04b5e529e00397e477f493905456d410c0691ea2659f1f1681149376601931253884b9ad3f0f64dd5c3e7d57f4a3864d1576253056
6
+ metadata.gz: 4fe5edfe3875669399eab479e38cab13b549926348f0d402796f66b5f19c914e95e3f15b088e91292575436cb838cdfd57cf82ed980e493859602ee16d2c3e68
7
+ data.tar.gz: 5e3557307cc24027184dc95eca8eb6945815f7b5b99a0182618a4ccee64fcd083b401421d5fd08c5eb71a3c2ecea7594ee53329b318399ac21d7e1cb0f2d8e4c
data/README.md CHANGED
@@ -50,7 +50,7 @@ end
50
50
  # app/controllers/admin/users_controller
51
51
  class Admin::UsersController < Admin::ApplicationController
52
52
  self.theme_name = 'account'
53
- self.options = { mapping_actions: { edit: 'form' } }
53
+ self.prefix_options = { mapping_actions: { edit: 'form' } }
54
54
  end
55
55
  ```
56
56
 
@@ -77,17 +77,46 @@ but still can be rendered by `admin/application#edit` action
77
77
  For `admin/users#edit` action, since `mapping_actions` option is set, `edit` will be mapped to `form`.
78
78
  Therefore, the lookup folder order of `admin/users#edit` becomes:
79
79
 
80
+ - app/views/admin/users/edit
80
81
  - app/views/admin/users/form
81
82
  - app/views/admin/users
83
+ - app/views/secure/edit
82
84
  - app/views/secure/form
83
85
  - app/views/secure
86
+ - app/views/admin/application/edit
84
87
  - app/views/admin/application/form
85
88
  - app/views/admin/application
89
+ - app/views/secure/edit
86
90
  - app/views/secure/form
87
91
  - app/views/secure
92
+ - app/views/application/edit
88
93
  - app/views/application/form
89
94
  - app/views/application
90
95
 
96
+ ## Advanced Usage
97
+
98
+ It is possible to override the `_prefixes` method to make more changes to the prefixes:
99
+
100
+ ```ruby
101
+ class ApplicationController < ActionController::Base
102
+ include Wallaby::View
103
+
104
+ def _prefixes
105
+ super do |prefixes|
106
+ prefixes << 'last_resort'
107
+ end
108
+ end
109
+ end
110
+ ```
111
+
112
+ Then the lookup folder order of `application#edit` becomes:
113
+
114
+ - app/views/application/edit
115
+ - app/views/application
116
+ - app/views/last_resort/edit
117
+ - app/views/last_resort
118
+
119
+
91
120
  ## Documentation
92
121
 
93
122
  - [API Reference](https://www.rubydoc.info/gems/wallaby-view)
@@ -88,8 +88,9 @@ module Wallaby
88
88
  # @return [Array<String>]
89
89
  def execute(&block)
90
90
  new_prefixes(&block).each_with_object([]) do |prefix, array|
91
- # Extend the prefix with action name suffix
92
- array << "#{prefix}/#{suffix}" << prefix
91
+ # Extend the prefix with actions
92
+ actions.each { |action| array << "#{prefix}/#{action}" }
93
+ array << prefix
93
94
  end
94
95
  end
95
96
 
@@ -110,13 +111,14 @@ module Wallaby
110
111
  end
111
112
  end
112
113
 
113
- # Action name suffix
114
- # @return [Hash]
115
- def suffix
116
- @suffix ||= mapped_action_name || action_name
114
+ # Action name actions
115
+ # @return [Array<String>]
116
+ def actions
117
+ @actions ||= [action_name, mapped_action_name].compact
117
118
  end
118
119
 
119
120
  # Insert theme name into the prefixes
121
+ # @param [Array] array
120
122
  def insert_themes_into(array)
121
123
  themes.each do |theme|
122
124
  index = array.index theme[:theme_path]
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Wallaby
4
4
  module View
5
- VERSION = '0.1.3' # :nodoc:
5
+ VERSION = '0.1.4' # :nodoc:
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wallaby-view
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tian Chen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-16 00:00:00.000000000 Z
11
+ date: 2020-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties