cache_tree 0.0.2 → 0.0.3

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.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/cache_tree.gemspec +1 -1
  3. data/lib/cache_tree.rb +14 -2
  4. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
data/cache_tree.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cache_tree}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["kazuyoshi tlacaelel"]
data/lib/cache_tree.rb CHANGED
@@ -69,9 +69,22 @@ module CacheTree
69
69
  include Tree::Node
70
70
 
71
71
  def initialize(target)
72
+ if target.is_a?(Hash)
73
+ initialize_from_hash(target)
74
+ else
75
+ initialize_from_object(target)
76
+ end
77
+ @stamp = generate_stamp
78
+ end
79
+
80
+ def initialize_from_hash(hash)
81
+ @name = hash[:name]
82
+ @value = hash[:value]
83
+ end
84
+
85
+ def initialize_from_object(target)
72
86
  @name = target.class.name.gsub(/([A-Z])/) { "_#{$1}" }.gsub(/^./, '').downcase
73
87
  @value = target.id
74
- @stamp = generate_stamp
75
88
  end
76
89
 
77
90
  def directory
@@ -168,7 +181,6 @@ module CacheTree
168
181
  nil
169
182
  end
170
183
 
171
-
172
184
  end
173
185
 
174
186
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cache_tree
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - kazuyoshi tlacaelel