gretel 1.0.5 → 1.0.6

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.
data/lib/gretel/crumbs.rb CHANGED
@@ -20,32 +20,29 @@ module Gretel
20
20
  all[name] = block
21
21
  end
22
22
 
23
- def get_crumb(name, *params)
23
+ def get_crumb(name, object = nil)
24
24
  raise "Crumb '#{name}' not found." unless all[name]
25
25
 
26
- @params = params # share the params so we can call it from link() and parent()
26
+ @object = object # share the object so we can call it from link() and parent()
27
27
  @link = nil
28
28
  @parent = nil
29
29
 
30
- all[name].call(*params)
30
+ all[name].call(object)
31
31
  Gretel::Crumb.new(@link, @parent)
32
32
  end
33
33
 
34
34
  def link(text, url, options = {})
35
- text = text.call(*@params) if text.is_a?(Proc)
36
- url = url.call(*@params) if url.is_a?(Proc)
35
+ text = text.call(@object) if text.is_a?(Proc)
36
+ url = url.call(@object) if url.is_a?(Proc)
37
37
 
38
38
  @link = Gretel::Link.new(text, url, options)
39
39
  end
40
40
 
41
- def parent(name, *params)
42
- name = name.call(*@params) if name.is_a?(Proc)
41
+ def parent(name, object = nil)
42
+ name = name.call(@object) if name.is_a?(Proc)
43
+ object = object.call(@object) if object.is_a?(Proc)
43
44
 
44
- params.each_with_index do |param, i|
45
- params[i] = param.call(&@params) if param.is_a?(Proc)
46
- end
47
-
48
- @parent = Gretel::Parent.new(name, *params)
45
+ @parent = Gretel::Parent.new(name, object)
49
46
  end
50
47
  end
51
48
  end
@@ -10,14 +10,14 @@ module Gretel
10
10
 
11
11
  def breadcrumb(*args)
12
12
  options = args.extract_options!
13
- name, params = args[0], args[1..-1]
13
+ name, object = args[0], args[1]
14
14
 
15
15
  if name
16
16
  @_breadcrumb_name = name
17
- @_breadcrumb_params = params
17
+ @_breadcrumb_object = object
18
18
  else
19
19
  if @_breadcrumb_name
20
- crumb = breadcrumb_for(@_breadcrumb_name, *@_breadcrumb_params, options)
20
+ crumb = breadcrumb_for(@_breadcrumb_name, @_breadcrumb_object, options)
21
21
  elsif options[:show_root_alone]
22
22
  crumb = breadcrumb_for(:root, options)
23
23
  end
@@ -36,14 +36,14 @@ module Gretel
36
36
  options[:link_last] = true
37
37
  separator = (options[:separator] || ">").html_safe
38
38
 
39
- name, params = args[0], args[1..-1]
39
+ name, object = args[0], args[1]
40
40
 
41
- crumb = Crumbs.get_crumb(name, *params)
41
+ crumb = Crumbs.get_crumb(name, object)
42
42
  out = link_to_if(link_last, crumb.link.text, crumb.link.url, crumb.link.options)
43
43
 
44
44
  while parent = crumb.parent
45
45
  last_parent = parent.name
46
- crumb = Crumbs.get_crumb(parent.name, *parent.params)
46
+ crumb = Crumbs.get_crumb(parent.name, parent.object)
47
47
  out = link_to(crumb.link.text, crumb.link.url, crumb.link.options) + " " + separator + " " + out
48
48
  end
49
49
 
data/lib/gretel/parent.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  module Gretel
2
2
  class Parent
3
- attr_accessor :name, :params
3
+ attr_accessor :name, :object
4
4
 
5
- def initialize(name, *params)
6
- @name, @params = name, params
5
+ def initialize(name, object)
6
+ @name, @object = name, object
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 5
9
- version: 1.0.5
8
+ - 6
9
+ version: 1.0.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Lasse Bunk