rails_pattern_view 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rails_pattern_view/version.rb +1 -1
- data/lib/rails_pattern_view.rb +7 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0474fd62ce59c290c888094096c783acc9b8521
|
4
|
+
data.tar.gz: c2b182bbbe44ffe8bce40ef1d69882ccbda3f545
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8398a81d28c605a0e027f6bfe70eaa480d9864e0032a1316445b78606c92e4e562c2f2c706f92c444b3e1c7120a7babb1af6817dda2b0b1400d3e576e88d7edc
|
7
|
+
data.tar.gz: b817fdd62a23824532b037824cca6de46a80582f97b79ee82a3847e336e23f15f86022ff3730209dd725a69ecee1ffadacc5c0eb46323fd488fe3b660cb2282b
|
data/lib/rails_pattern_view.rb
CHANGED
@@ -5,20 +5,23 @@ module RailsPatternView
|
|
5
5
|
|
6
6
|
module ClassMethods
|
7
7
|
def use_pattern(pattern, opts = {})
|
8
|
-
only
|
9
|
-
except
|
10
|
-
mapping
|
8
|
+
only = opts[:only] || []
|
9
|
+
except = opts[:except] || []
|
10
|
+
mapping = opts[:mapping] || {}
|
11
|
+
template = opts[:template] || {}
|
12
|
+
raise 'cannot mix `template` & `mapping`' if template.present? && mapping.present?
|
11
13
|
raise 'cannot mix `only` & `except`' if only.present? && except.present?
|
12
14
|
raise '`only` must be Array type' if !only.is_a? Array
|
13
15
|
raise '`except` must be Array type' if !except.is_a? Array
|
14
16
|
raise '`mapping` must be Hash type' if !mapping.is_a? Hash
|
17
|
+
actions = (only.present? ? only : action_methods.to_a) - except
|
18
|
+
mapping[template] = actions if template.present?
|
15
19
|
mappings = resolve_mapping(mapping)
|
16
20
|
|
17
21
|
define_method(:pattern_name) { pattern }
|
18
22
|
define_method(:pattern_actions_mapping) { mappings }
|
19
23
|
|
20
24
|
private :pattern_name, :pattern_actions_mapping
|
21
|
-
actions = (only.present? ? only : action_methods.to_a) - except
|
22
25
|
before_filter :filter_render, :only => actions
|
23
26
|
end
|
24
27
|
|