simply_configurable 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,7 +1,10 @@
1
1
  = Simply Configurable
2
2
 
3
+ == Version 0.1.0
4
+ * Added capability to nest SimplyConfigurable classes (see README)
5
+
3
6
  == Version 0.0.2
4
- * Allowing nested hash values (before, "MyClass.config :foo => {}" threw an error)
7
+ * Allows nested hash values (before, "MyClass.config :foo => {}" threw an error)
5
8
 
6
9
  == Version 0.0.1
7
10
  * Initial release
data/README.rdoc CHANGED
@@ -43,3 +43,24 @@ The #config method is defined on both the class and its instances, so it may be
43
43
 
44
44
  This library uses the HashWithIndifferentAccess class of the ActiveSupport library, allowing you to access/set config values by either symbol or string.
45
45
 
46
+ == Nesting
47
+
48
+ Any subclasses of a SimplyConfigurable class will also be SimplyConfigurable. The subclass will inherit all config values from its ancestors, but any values set on the subclass will not overwrite those on the ancestors.
49
+
50
+ For example:
51
+
52
+ class Foo
53
+ include SimplyConfigurable
54
+
55
+ config :color => 'red'
56
+ config :style => 'awesome'
57
+ end
58
+
59
+ class Bar < Foo
60
+ config :style => 'less awesome'
61
+ end
62
+
63
+ Foo.config[:style] # returns 'awesome'
64
+ Bar.config[:style] # returns 'less awesome'
65
+ Bar.config[:color] # returns 'red'
66
+
@@ -1,3 +1,3 @@
1
1
  module SimplyConfigurable
2
- VERSION = '0.0.2'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -21,7 +21,17 @@ module SimplyConfigurable
21
21
  @config.merge!(options || {})
22
22
  end
23
23
 
24
- @config
24
+ superclass_config.merge(@config)
25
+ end
26
+
27
+ private
28
+
29
+ def superclass_config
30
+ if self.superclass.include?(SimplyConfigurable)
31
+ self.superclass.config
32
+ else
33
+ {}.with_indifferent_access
34
+ end
25
35
  end
26
36
 
27
37
  end
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 2
10
- version: 0.0.2
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - David Dawson