configatron 2.3.0 → 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,9 +18,8 @@ class Class
18
18
  #
19
19
  # Foo.to_configatron.bar # => :bar
20
20
  # A::B::C.to_configatron.d # => 'D'
21
- def to_configatron
22
- name_spaces = self.name.split("::").collect{|s| s.methodize}
23
- configatron.send_with_chain(name_spaces)
21
+ def to_configatron(*args)
22
+ self.name.to_configatron(*args)
24
23
  end
25
24
 
26
25
  end
@@ -1,5 +1,11 @@
1
1
  class String # :nodoc:
2
2
 
3
+ def to_configatron(*args)
4
+ name_spaces = (args + self.split("::")).flatten
5
+ name_spaces.collect!{|s| s.to_s.methodize}
6
+ configatron.send_with_chain(name_spaces)
7
+ end
8
+
3
9
  def underscore # :nodoc:
4
10
  self.to_s.gsub(/::/, '/').
5
11
  gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
@@ -16,6 +16,32 @@ class Configatron
16
16
  @_store
17
17
  end
18
18
 
19
+ def heirarchy
20
+ path = [@_name]
21
+ parent = @_parent
22
+ until parent.nil?
23
+ path << parent.instance_variable_get('@_name')
24
+ parent = parent.instance_variable_get('@_parent')
25
+ end
26
+ path.compact!
27
+ path.reverse!
28
+ path.join('.')
29
+ end
30
+
31
+ def configatron_keys
32
+ return @_store.keys.collect{|k| k.to_s}.sort
33
+ end
34
+
35
+ # Checks whether or not a parameter exists
36
+ #
37
+ # Examples:
38
+ # configatron.i.am.alive = 'alive!'
39
+ # configatron.i.am.exists?(:alive) # => true
40
+ # configatron.i.am.exists?(:dead) # => false
41
+ def exists?(name)
42
+ @_store.has_key?(name.to_sym) || @_store.has_key?(name.to_s)
43
+ end
44
+
19
45
  def inspect
20
46
  path = [@_name]
21
47
  parent = @_parent
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configatron
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - markbates
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-22 00:00:00 -04:00
12
+ date: 2009-05-01 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency