reality-core 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/reality/base_element.rb +6 -6
- data/reality-core.gemspec +1 -1
- data/test/test_base_element.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d24305253302c7aa643f825e17153efba609f57d
|
4
|
+
data.tar.gz: 3a8f9a866751c58b4fae0d1cc1cace8dd97205a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f9cfe5ec01a41b474e6520ce4aa2ec7b360976570f05f8fb362c64675e9c8cf100ed472a2320f626033da1dd02e0390cb08582a0e01295da3bc8378d49dbc95
|
7
|
+
data.tar.gz: d6f572d5cbfa2e6cdd920b49f691a23b19f16e5874a6023310f221ab68fbef1b2e83a2a3067d79b39f848fa8d1e35f72d8b7e82c1ee27c33103938807c86f702
|
data/lib/reality/base_element.rb
CHANGED
@@ -40,7 +40,7 @@ module Reality #nodoc
|
|
40
40
|
def self.base_element(options = {})
|
41
41
|
type = Class.new(BaseElement)
|
42
42
|
|
43
|
-
|
43
|
+
container_key = options[:container_key]
|
44
44
|
pre_config_code = options[:pre_config_code]
|
45
45
|
has_name = !!options[:name]
|
46
46
|
has_key = !!options[:key]
|
@@ -50,12 +50,12 @@ module Reality #nodoc
|
|
50
50
|
parameters = []
|
51
51
|
initializers = ''
|
52
52
|
|
53
|
-
if
|
54
|
-
code += "attr_reader :#{
|
55
|
-
parameters <<
|
53
|
+
if container_key
|
54
|
+
code += "attr_reader :#{container_key}\n"
|
55
|
+
parameters << container_key
|
56
56
|
initializers += <<-RUBY
|
57
|
-
@#{
|
58
|
-
raise "Nil #{
|
57
|
+
@#{container_key} = #{container_key}
|
58
|
+
raise "Nil #{container_key} parameter passed to #{self.class} instance" if @#{container_key}.nil?
|
59
59
|
RUBY
|
60
60
|
end
|
61
61
|
|
data/reality-core.gemspec
CHANGED
data/test/test_base_element.rb
CHANGED
@@ -37,7 +37,7 @@ class Reality::TestBaseElement < Reality::TestCase
|
|
37
37
|
class TestElementA < Reality.base_element
|
38
38
|
end
|
39
39
|
|
40
|
-
class TestElementB < Reality.base_element(:
|
40
|
+
class TestElementB < Reality.base_element(:container_key => 'container')
|
41
41
|
end
|
42
42
|
|
43
43
|
class TestElementC < Reality.base_element(:name => true)
|
@@ -49,7 +49,7 @@ class Reality::TestBaseElement < Reality::TestCase
|
|
49
49
|
class TestElementE < Reality.base_element(:name => true, :key => true)
|
50
50
|
end
|
51
51
|
|
52
|
-
class TestElementF < Reality.base_element(:
|
52
|
+
class TestElementF < Reality.base_element(:container_key => 'container', :name => true, :key => true)
|
53
53
|
end
|
54
54
|
|
55
55
|
class TestElementG < Reality.base_element(:pre_config_code => 'self.foo = 1')
|
@@ -96,8 +96,8 @@ class Reality::TestBaseElement < Reality::TestCase
|
|
96
96
|
end
|
97
97
|
|
98
98
|
begin
|
99
|
-
TestElementG.new do |
|
100
|
-
assert_equal
|
99
|
+
TestElementG.new do |te|
|
100
|
+
assert_equal te.foo, 1
|
101
101
|
end
|
102
102
|
end
|
103
103
|
end
|