rails_nav 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/rails_nav.rb +21 -6
  2. data/rails_nav.gemspec +1 -1
  3. metadata +17 -7
data/lib/rails_nav.rb CHANGED
@@ -4,7 +4,7 @@
4
4
  ##
5
5
  #
6
6
  def Nav.version()
7
- '1.1.0'
7
+ '1.2.0'
8
8
  end
9
9
 
10
10
  def Nav.dependencies
@@ -28,7 +28,7 @@
28
28
  ##
29
29
  #
30
30
  def Nav.for(*args, &block)
31
- new(*args, &block)
31
+ new(*args, &block).tap{|nav| nav.strategy = :instance_exec}
32
32
  end
33
33
 
34
34
  def for(controller)
@@ -43,17 +43,25 @@
43
43
  attr_accessor(:name)
44
44
  attr_accessor(:block)
45
45
  attr_accessor(:controller)
46
+ attr_accessor(:strategy)
46
47
 
47
- def initialize(name = 'nav', &block)
48
+ def initialize(name = :nav, &block)
48
49
  @name = name.to_s
49
50
  @block = block
50
51
  @already_computed_active = false
51
52
  @controller = nil
53
+ @strategy = :call
52
54
  end
53
55
 
54
56
  def build!
55
- @controller.instance_exec(self, &@block)
56
- self
57
+ nav = self
58
+ case @strategy
59
+ when :instance_exec
60
+ @controller.instance_exec(nav, &@block)
61
+ when :call
62
+ @block.call(nav)
63
+ end
64
+ nav
57
65
  end
58
66
 
59
67
  def link(*args, &block)
@@ -160,7 +168,14 @@
160
168
  def compute_active!
161
169
  block = @compute_active
162
170
  args = [self].slice(0 .. (block.arity < 0 ? -1 : block.arity))
163
- @active = @controller.send(:instance_exec, *args, &block)
171
+
172
+ @active =
173
+ case @nav.strategy
174
+ when :instance_exec
175
+ @controller.send(:instance_exec, *args, &block)
176
+ when :call
177
+ block.call(*args)
178
+ end
164
179
  ensure
165
180
  @already_computed_active = true
166
181
  end
data/rails_nav.gemspec CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification::new do |spec|
5
5
  spec.name = "rails_nav"
6
- spec.version = "1.1.0"
6
+ spec.version = "1.2.0"
7
7
  spec.platform = Gem::Platform::RUBY
8
8
  spec.summary = "rails_nav"
9
9
  spec.description = "description: rails_nav kicks the ass"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_nav
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-16 00:00:00.000000000 Z
12
+ date: 2012-06-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails_current
16
- requirement: &70209172359780 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '1.6'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70209172359780
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '1.6'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rails_helper
27
- requirement: &70209172359240 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,7 +37,12 @@ dependencies:
32
37
  version: '1.2'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *70209172359240
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '1.2'
36
46
  description: ! 'description: rails_nav kicks the ass'
37
47
  email: ara.t.howard@gmail.com
38
48
  executables: []
@@ -63,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
73
  version: '0'
64
74
  requirements: []
65
75
  rubyforge_project: codeforpeople
66
- rubygems_version: 1.8.11
76
+ rubygems_version: 1.8.23
67
77
  signing_key:
68
78
  specification_version: 3
69
79
  summary: rails_nav