tree_decorator 0.1.3 → 0.1.4

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/README.md CHANGED
@@ -16,14 +16,14 @@ For example:
16
16
  end
17
17
 
18
18
  hanger = TreeDecorator::ObjectHanger.new(
19
- Thing.roots,
19
+ Thing.roots.to_a,
20
20
  :children_method => :children,
21
21
  :content_method => :name
22
22
  )
23
23
 
24
- hanger.outer {|content| "<ul>#{content}</ul>"}
25
- hanger.inner {|content| "<li>#{content}</li>"}
26
- hanger.element {|content| "<span class=\"thing\">#{content}</span>"}
24
+ hanger.outer {|content| content_tag('ul', content.html_safe)}
25
+ hanger.inner {|content| content_tag('li', content.html_safe)}
26
+ hanger.element {|content| content_tag('span', content.html_safe, :class => 'thing')}
27
27
 
28
28
  hanger.tree #----> outputs a nested HTML unordered list with each thing's name
29
29
  # in a span of class 'thing'.
@@ -26,12 +26,12 @@ module TreeDecorator
26
26
 
27
27
  def populate_with_children(object)
28
28
  content = Hash.new
29
- children = object.respond_to?(:each) ? object : object.send(children_method)
29
+ children = object.respond_to?(:each) ? object.to_a : object.send(children_method)
30
30
 
31
31
  if children and !children.empty?
32
32
  children.each do |child|
33
33
  unless child.respond_to? content_method
34
- raise "Child does not have :#{content_method} method: #{child.inspect}"
34
+ raise "#{child.class.to_s} does not have :#{content_method} method: #{child.inspect}"
35
35
  end
36
36
  content[child.send(content_method)] = populate_with_children(child)
37
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tree_decorator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: