named_value_class 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/named_value_class.rb +18 -3
- metadata +3 -2
data/lib/named_value_class.rb
CHANGED
@@ -18,11 +18,26 @@ def NamedValueClass(klass_name,superclass, &block)
|
|
18
18
|
instance_variable_set "@#{attr}", val
|
19
19
|
end
|
20
20
|
|
21
|
-
# THINK is this making it harder than it needs to be?
|
22
21
|
named_values_module = self.class.const_get('NamedValues')
|
23
22
|
named_values_collection = named_values_module.const_get('Collection')
|
24
|
-
|
25
|
-
|
23
|
+
begin
|
24
|
+
self.class.const_set(@name, self)
|
25
|
+
named_values_module.const_set(@name, self)
|
26
|
+
rescue NameError
|
27
|
+
name_error_name = "NameError_#{@name}"
|
28
|
+
self.class.const_set(name_error_name, self)
|
29
|
+
named_values_module.const_set(name_error_name, self)
|
30
|
+
self.class.class_eval <<-EVAL
|
31
|
+
def self.#{@name}()
|
32
|
+
#{name_error_name}
|
33
|
+
end
|
34
|
+
EVAL
|
35
|
+
named_values_module.module_eval <<-EVAL
|
36
|
+
def self.#{@name}()
|
37
|
+
#{name_error_name}
|
38
|
+
end
|
39
|
+
EVAL
|
40
|
+
end
|
26
41
|
named_values_collection << self
|
27
42
|
end
|
28
43
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: named_value_class
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,8 @@ bindir: bin
|
|
11
11
|
cert_chain: []
|
12
12
|
date: 2011-11-16 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
|
-
description:
|
14
|
+
description: Quickly add class delegate constants which output their names, not their
|
15
|
+
values. This may be desirable for some DSLs.
|
15
16
|
email: mgarriss@gmail.com
|
16
17
|
executables: []
|
17
18
|
extensions: []
|