tree_decorator 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -16,14 +16,13 @@ For example:
16
16
  end
17
17
 
18
18
  hanger = TreeDecorator::ObjectHanger.new(
19
- Thing.roots.to_a,
20
- :children_method => :children,
21
- :content_method => :name
19
+ Thing.roots,
20
+ :children_method => :children
22
21
  )
23
22
 
24
23
  hanger.outer {|content| content_tag('ul', content.html_safe)}
25
24
  hanger.inner {|content| content_tag('li', content.html_safe)}
26
- hanger.element {|content| content_tag('span', content.html_safe, :class => 'thing')}
25
+ hanger.element {|content| content_tag('span', content.name, :class => 'thing')}
27
26
 
28
27
  hanger.tree #----> outputs a nested HTML unordered list with each thing's name
29
28
  # in a span of class 'thing'.
@@ -10,7 +10,6 @@ module TreeDecorator
10
10
  def initialize(root, args = {})
11
11
  @root = root
12
12
  @children_method = args[:children_method]
13
- @content_method = args[:content_method]
14
13
  @tree = hash
15
14
  end
16
15
 
@@ -30,10 +29,7 @@ module TreeDecorator
30
29
 
31
30
  if children and !children.empty?
32
31
  children.each do |child|
33
- unless child.respond_to? content_method
34
- raise "#{child.class.to_s} does not have :#{content_method} method: #{child.inspect}"
35
- end
36
- content[child.send(content_method)] = populate_with_children(child)
32
+ content[child] = populate_with_children(child)
37
33
  end
38
34
  end
39
35
 
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.5
4
+ version: 0.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: