jonuts-figure8 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/figure8/collection_mixin.rb +3 -1
- data/lib/figure8/configurator.rb +12 -13
- metadata +3 -3
@@ -12,6 +12,8 @@ module Figure8
|
|
12
12
|
@finder = attribute
|
13
13
|
end
|
14
14
|
end
|
15
|
+
|
16
|
+
@all ||= []
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
@@ -33,7 +35,7 @@ module Figure8
|
|
33
35
|
|
34
36
|
def add_self_to_collection
|
35
37
|
self.class.all ||= []
|
36
|
-
self.class.all << self unless self.class[self]
|
38
|
+
self.class.all << self unless self.class[send(self.class.finder)]
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
data/lib/figure8/configurator.rb
CHANGED
@@ -3,15 +3,7 @@ module Figure8
|
|
3
3
|
|
4
4
|
# NOTE: i suck
|
5
5
|
def self.extended(base)
|
6
|
-
base.
|
7
|
-
class << self; attr_reader :scope; end
|
8
|
-
|
9
|
-
@scope = base
|
10
|
-
end
|
11
|
-
|
12
|
-
Object.class_eval("class #{base.name}::Config; end; class #{base.name}::Group; end")
|
13
|
-
|
14
|
-
base::Config.class_eval do
|
6
|
+
base.const_set("Config", Class.new {
|
15
7
|
include CollectionMixin
|
16
8
|
|
17
9
|
find_by :name
|
@@ -23,9 +15,9 @@ module Figure8
|
|
23
15
|
end
|
24
16
|
|
25
17
|
attr_accessor :name, :value
|
26
|
-
|
18
|
+
}) unless base.constants.include?("Config")
|
27
19
|
|
28
|
-
base
|
20
|
+
base.const_set("Group", Class.new {
|
29
21
|
include CollectionMixin
|
30
22
|
|
31
23
|
class << self; attr_reader :scope; end
|
@@ -58,8 +50,14 @@ module Figure8
|
|
58
50
|
def set(name, val)
|
59
51
|
find_or_create_config(name).value = val
|
60
52
|
end
|
53
|
+
}) unless base.constants.include?("Group")
|
54
|
+
|
55
|
+
base.class_eval do
|
56
|
+
class << self; attr_reader :scope; end
|
61
57
|
|
58
|
+
@scope = base
|
62
59
|
end
|
60
|
+
|
63
61
|
end
|
64
62
|
|
65
63
|
def set(name, val=nil, &blk)
|
@@ -68,12 +66,12 @@ module Figure8
|
|
68
66
|
elsif val.nil?
|
69
67
|
raise ArgumentError, "you must supply a value with your setting"
|
70
68
|
else
|
71
|
-
find_or_create(
|
69
|
+
find_or_create(const_get("Config"), name).value = val
|
72
70
|
end
|
73
71
|
end
|
74
72
|
|
75
73
|
def group(name, &blk)
|
76
|
-
find_or_create(
|
74
|
+
find_or_create(const_get("Group"), name).instance_eval(&blk)
|
77
75
|
end
|
78
76
|
|
79
77
|
def [](name)
|
@@ -94,6 +92,7 @@ module Figure8
|
|
94
92
|
def find_or_create(klass, name)
|
95
93
|
klass[name] || klass.new(:name => name)
|
96
94
|
end
|
95
|
+
|
97
96
|
end
|
98
97
|
end
|
99
98
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jonuts-figure8
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jonah honeyman
|
@@ -13,7 +13,7 @@ date: 2009-04-17 00:00:00 -07:00
|
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
16
|
-
description: configuration encapsulation
|
16
|
+
description: configuration encapsulation elation
|
17
17
|
email: jonah@honeyman.org
|
18
18
|
executables: []
|
19
19
|
|
@@ -55,6 +55,6 @@ rubyforge_project:
|
|
55
55
|
rubygems_version: 1.2.0
|
56
56
|
signing_key:
|
57
57
|
specification_version: 2
|
58
|
-
summary: configuration encapsulation
|
58
|
+
summary: configuration encapsulation elation
|
59
59
|
test_files: []
|
60
60
|
|