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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c312462e65fb4c4e41a6d68be3a5a680f6fabf1f
4
- data.tar.gz: ddfadf88e777b027f30d5b34c6138ffe5b3412d4
3
+ metadata.gz: c0474fd62ce59c290c888094096c783acc9b8521
4
+ data.tar.gz: c2b182bbbe44ffe8bce40ef1d69882ccbda3f545
5
5
  SHA512:
6
- metadata.gz: c0ee1658ac9dde2b43473a3fd44e942b4eb5330ea98dac339cfb9230c9b66ba3f3618c075ec98e7e25e2927742c873f1e2eaedd42195a00d1da4d8f5c9f79c05
7
- data.tar.gz: f58456d6975fd8fb4267ab6fd706ad2a4697b495d477a1435712d6b4a30f6857b53d116a9fc2eda6aecfa485427f2aed4dadaab3eafa1d4f839e83bc422865d4
6
+ metadata.gz: 8398a81d28c605a0e027f6bfe70eaa480d9864e0032a1316445b78606c92e4e562c2f2c706f92c444b3e1c7120a7babb1af6817dda2b0b1400d3e576e88d7edc
7
+ data.tar.gz: b817fdd62a23824532b037824cca6de46a80582f97b79ee82a3847e336e23f15f86022ff3730209dd725a69ecee1ffadacc5c0eb46323fd488fe3b660cb2282b
@@ -1,3 +1,3 @@
1
1
  module RailsPatternView
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -5,20 +5,23 @@ module RailsPatternView
5
5
 
6
6
  module ClassMethods
7
7
  def use_pattern(pattern, opts = {})
8
- only = opts[:only] || []
9
- except = opts[:except] || []
10
- mapping = opts[: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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_pattern_view
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tien Nguyen