tree_decorator 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -16,7 +16,7 @@ For example:
16
16
  end
17
17
 
18
18
  hanger = TreeDecorator::ObjectHanger.new(
19
- Thing.roots.first,
19
+ Thing.roots,
20
20
  :children_method => :children,
21
21
  :content_method => :name
22
22
  )
@@ -20,15 +20,14 @@ module TreeDecorator
20
20
 
21
21
  private
22
22
  def get_hash_from_objects
23
- content = Hash.new
24
- content[@root.send(content_method)] = populate_with_children(@root)
25
- return content
23
+ objects = @root.kind_of?(Array) ? @root : [@root]
24
+ populate_with_children(objects)
26
25
  end
27
26
 
28
27
  def populate_with_children(object)
29
- content = Hash.new
30
- children = object.send(children_method)
31
-
28
+ content = Hash.new
29
+ children = object.kind_of?(Array) ? object : object.send(children_method)
30
+
32
31
  if children and !children.empty?
33
32
  children.each do |child|
34
33
  content[child.send(content_method)] = populate_with_children(child)
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.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: