conject 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/doc/inheritance_woes.txt +57 -0
- data/lib/conject/class_ext_construct_with.rb +99 -56
- data/lib/conject/version.rb +1 -1
- data/spec/acceptance/regression/basic_composition_spec.rb +1 -1
- data/spec/acceptance/regression/basic_object_creation_spec.rb +1 -1
- data/spec/acceptance/regression/inherited_dependencies_spec.rb +253 -0
- data/spec/acceptance/regression/inject_object_context_spec.rb +1 -1
- data/spec/acceptance/regression/nested_contexts_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -0
- data/spec/support/conject_helpers.rb +5 -0
- data/spec/test_data/basic_composition/special_guest.rb +4 -0
- data/spec/test_data/basic_composition/very_special_guest.rb +4 -0
- data/spec/test_data/inheritance/body.rb +5 -0
- data/spec/test_data/inheritance/car.rb +3 -0
- data/spec/test_data/inheritance/emblem.rb +5 -0
- data/spec/test_data/inheritance/malibu.rb +7 -0
- data/spec/test_data/inheritance/vehicle.rb +11 -0
- data/spec/test_data/inheritance/wheel.rb +5 -0
- metadata +30 -9
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
|
|
2
|
+
class Mammal
|
|
3
|
+
construct_with :fur
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
class Cat < Mammal
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
Things Cat will inherit from Mammal:
|
|
11
|
+
|
|
12
|
+
.new
|
|
13
|
+
.actual_new
|
|
14
|
+
|
|
15
|
+
.object_definition
|
|
16
|
+
|
|
17
|
+
.object_context_prep (indirectly)
|
|
18
|
+
|
|
19
|
+
#initialize(component_map) (will be overridden)
|
|
20
|
+
#actual_initialize (will get stomped)
|
|
21
|
+
|
|
22
|
+
Calling Cat.new
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
Rationale: Why does Conject re-implement .new for classes that use construct_with ?
|
|
26
|
+
|
|
27
|
+
To get in front of normal object construction. I wanted to get instances built up
|
|
28
|
+
before the normal, user-defined #initialize gets called.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
4 initialize cases for subclasses
|
|
37
|
+
subclass has defined its own #initialize and calls super
|
|
38
|
+
subclass has defined its own #initialize and DOES NOT CALL super
|
|
39
|
+
X
|
|
40
|
+
superclass defined its own #initialize and it has been wrapped by Conject to accept component map
|
|
41
|
+
superclass defined its own #initialize, but it HAS NOT BEEN WRAPPED YET
|
|
42
|
+
superclass DOES NOT DEFINE its own #initialize, and it has been wrapped by Conject
|
|
43
|
+
superclass DOES NOT DEFINE its own #initialize, but it HAS NOT BEEN WRAPPED YET
|
|
44
|
+
|
|
45
|
+
These circumstances affect when/if set_comonents gets called in the superclass
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class A
|
|
49
|
+
construct_with :b
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
class Aa < A
|
|
53
|
+
construct_with :b, :c
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
- if A gets instantiated first, A#actual_initialize is created and A#initialize is rewritten
|
|
57
|
+
- Instantiating Aa invokes actual_initialize with the component_map which invokes Conjected A#initialize ... which invokes :actual_initialize which has been re-aliased by the subclass and NO LONGER REFERS TO THE ORIGINAL CONSTRUCTOR
|
|
@@ -4,93 +4,136 @@ class Class
|
|
|
4
4
|
def construct_with(*syms)
|
|
5
5
|
klass = self
|
|
6
6
|
|
|
7
|
+
#
|
|
8
|
+
# Create the .object_definition accessor for this class.
|
|
9
|
+
#
|
|
10
|
+
# The ObjectDefinition stores information # on the dependencies required to
|
|
11
|
+
# build new instances.
|
|
12
|
+
#
|
|
7
13
|
object_def = Conject::ObjectDefinition.new(:owner => klass, :component_names => syms)
|
|
8
14
|
klass.meta_def :object_definition do
|
|
9
|
-
|
|
15
|
+
@object_definition
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# TODO: actually, just use meta_eval here to set the ivar and move on.
|
|
19
|
+
klass.meta_def :set_object_definition do |od| #XXX
|
|
20
|
+
@object_definition = od
|
|
10
21
|
end
|
|
22
|
+
klass.set_object_definition(object_def) # XXX
|
|
23
|
+
klass.meta_eval do private :set_object_definition end # XXX
|
|
11
24
|
|
|
12
25
|
|
|
26
|
+
#
|
|
27
|
+
# Define internal accessor methods for instances of klass
|
|
28
|
+
#
|
|
29
|
+
|
|
30
|
+
# The internal hash of dependencies, keyed by name:
|
|
13
31
|
klass.class_def_private :components do
|
|
14
32
|
@_components ||= {}
|
|
15
33
|
end
|
|
34
|
+
# Have the components been set for this instance yet?
|
|
35
|
+
klass.class_def_private :components_set? do
|
|
36
|
+
!@_components.nil?
|
|
37
|
+
end
|
|
16
38
|
|
|
39
|
+
# Define an internal reader method per dependency:
|
|
17
40
|
syms.each do |object_name|
|
|
18
41
|
class_def_private object_name do
|
|
19
42
|
components[object_name]
|
|
20
43
|
end
|
|
21
44
|
end
|
|
22
45
|
|
|
46
|
+
# Define the internal setter method that installs dependencies
|
|
47
|
+
# in an instance of klass.
|
|
48
|
+
# #set_components respects the rules set forth in the ObjectDefinition
|
|
49
|
+
# for this class, and will raise a detailed exception if the rules
|
|
50
|
+
# are violated.
|
|
23
51
|
klass.class_def_private :set_components do |component_map|
|
|
24
|
-
|
|
52
|
+
return if components_set? # do not repeat. In inheritance town, a superclass must currently rely on all
|
|
53
|
+
# of its deps to be declared and set by subclass functionality.
|
|
54
|
+
|
|
55
|
+
obj_def = self.class.object_definition
|
|
56
|
+
required = obj_def.component_names
|
|
25
57
|
provided = component_map.keys
|
|
26
58
|
if required.to_set != provided.to_set
|
|
59
|
+
# Explain the diff between what was required and what was actually provided:
|
|
27
60
|
raise Conject::CompositionError.new(
|
|
28
|
-
:object_definition =>
|
|
61
|
+
:object_definition => obj_def,
|
|
29
62
|
:required => required,
|
|
30
63
|
:provided => provided)
|
|
31
64
|
end
|
|
32
65
|
|
|
66
|
+
# set all the components
|
|
33
67
|
components.clear.merge! component_map
|
|
34
|
-
|
|
35
68
|
end
|
|
36
69
|
|
|
37
|
-
#
|
|
38
|
-
#
|
|
39
|
-
object_context_prep
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
# Alias :new such that we can wrap and invoke it later
|
|
44
|
-
klass.meta_eval do
|
|
45
|
-
alias_method :actual_new, :new
|
|
70
|
+
# .object_context_prep is used internally by klass to maintain some state regarding
|
|
71
|
+
# its internal restructuring.
|
|
72
|
+
klass.meta_def :object_context_prep do
|
|
73
|
+
@object_context_prep ||= {
|
|
74
|
+
:initialize_has_been_wrapped => false
|
|
75
|
+
}
|
|
46
76
|
end
|
|
77
|
+
klass.meta_eval do private :object_context_prep end
|
|
78
|
+
|
|
79
|
+
unless klass.methods.include?(:actual_new) # only do this once per family tree (subclasses will inherit the Conjected .new)
|
|
80
|
+
# Alias :new such that we can wrap and invoke it later
|
|
81
|
+
klass.meta_eval do
|
|
82
|
+
alias_method :actual_new, :new
|
|
83
|
+
end
|
|
47
84
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
# Override default :new behavior for this class.
|
|
86
|
+
#
|
|
87
|
+
# The .new method is rewritten to accept a single argument:
|
|
88
|
+
# component_map: a Hash containing all required objects to construct a new instance.
|
|
89
|
+
# Keys are expected to be symbols.
|
|
90
|
+
#
|
|
91
|
+
# If user defines their own #initialize method, all components sent into .new
|
|
92
|
+
# will be installed BEFORE the user-defined #initialize, and it may accept arguments thusly:
|
|
93
|
+
# * zero args. Nothing will be passed to #initialize
|
|
94
|
+
# * single arg. The component_map will be passed.
|
|
95
|
+
# * var args (eg, def initialize(*args)). args[0] will be the component map. NO OTHER ARGS WILL BE PASSED. See Footnote a)
|
|
96
|
+
#
|
|
97
|
+
klass.meta_def :new do |component_map|
|
|
98
|
+
|
|
99
|
+
# We only want to do the following one time, but we've waited until now
|
|
100
|
+
# in order to make sure our metaprogramming didn't get ahead of the user's
|
|
101
|
+
# own definition of initialize:
|
|
102
|
+
unless object_context_prep[:initialize_has_been_wrapped]
|
|
103
|
+
# Define a new wrapper'd version of initialize that accepts and uses a component map
|
|
104
|
+
init_alias = "original_#{self.name}_initialize".to_sym
|
|
105
|
+
alias_method init_alias, :initialize
|
|
106
|
+
class_def :initialize do |component_map|
|
|
107
|
+
if self.class.has_object_definition?
|
|
108
|
+
# Apply the given components
|
|
109
|
+
set_components component_map
|
|
110
|
+
else
|
|
111
|
+
raise "#{self.class} has an ancestor that uses construct_with, but has not declared any component dependencies. Will not be able to instantiate!"
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Invoke the normal initialize method.
|
|
115
|
+
# User-defined initialize method may accept 0 args, or it may accept a single arg
|
|
116
|
+
# which will be the component map.
|
|
117
|
+
arg_count = method(init_alias).arity
|
|
118
|
+
case arg_count
|
|
119
|
+
when 0
|
|
120
|
+
self.send init_alias
|
|
121
|
+
|
|
122
|
+
when 1, -1 # See Footnote a) at the bottom of this file
|
|
123
|
+
self.send init_alias, component_map
|
|
124
|
+
|
|
125
|
+
else
|
|
126
|
+
# We're not equipped to handle this
|
|
127
|
+
raise "User-defined initialize method defined with #{arg_count} parameters; must either be 0, other wise 1 or -1 (varargs) to receive the component map."
|
|
128
|
+
end
|
|
86
129
|
end
|
|
130
|
+
# Make a note that the initialize wrapper has been applied
|
|
131
|
+
object_context_prep[:initialize_has_been_wrapped] = true
|
|
87
132
|
end
|
|
88
|
-
# Make a note that the initialize wrapper has been applied
|
|
89
|
-
object_context_prep[:initialize_has_been_wrapped] = true
|
|
90
|
-
end
|
|
91
133
|
|
|
92
|
-
|
|
93
|
-
|
|
134
|
+
# Instantiate an instance
|
|
135
|
+
actual_new component_map
|
|
136
|
+
end
|
|
94
137
|
end
|
|
95
138
|
end
|
|
96
139
|
|
data/lib/conject/version.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
2
2
|
|
|
3
3
|
describe "basic object composition" do
|
|
4
|
-
subject { Conject.
|
|
4
|
+
subject { Conject.create_object_context(nil) }
|
|
5
5
|
|
|
6
6
|
before do
|
|
7
7
|
append_test_load_path "basic_composition"
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe "basic inheritance" do
|
|
4
|
+
subject { new_object_context }
|
|
5
|
+
|
|
6
|
+
before do
|
|
7
|
+
append_test_load_path "inheritance"
|
|
8
|
+
require 'vehicle'
|
|
9
|
+
require 'wheel'
|
|
10
|
+
require 'body'
|
|
11
|
+
require 'car'
|
|
12
|
+
require 'malibu'
|
|
13
|
+
require 'emblem'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
context "simple subclasses of a class that uses construct_with" do
|
|
17
|
+
it "gets built with its superclass's dependencies" do
|
|
18
|
+
# Check the base type object:
|
|
19
|
+
vehicle = subject[:vehicle]
|
|
20
|
+
vehicle.should be
|
|
21
|
+
vehicle.hit_body.should == "body!"
|
|
22
|
+
vehicle.hit_wheel.should == "wheel!"
|
|
23
|
+
|
|
24
|
+
# grab the subtype object:
|
|
25
|
+
car = subject[:car]
|
|
26
|
+
car.should be
|
|
27
|
+
car.hit_body.should == "body!"
|
|
28
|
+
car.hit_wheel.should == "wheel!"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
context "class three levels deep in inheritance, adding a dep" do
|
|
33
|
+
it "works" do
|
|
34
|
+
malibu = subject[:malibu]
|
|
35
|
+
malibu.hit_body.should == "body!"
|
|
36
|
+
malibu.hit_wheel.should == "wheel!"
|
|
37
|
+
malibu.hit_emblem.should == "chevy!"
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
context "[initializers]" do
|
|
42
|
+
context "superclass has 0-arg #initialize" do
|
|
43
|
+
class Mammal
|
|
44
|
+
construct_with :fur
|
|
45
|
+
attr_reader :temp
|
|
46
|
+
def initialize
|
|
47
|
+
@temp = 98.6
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
class Fur; end
|
|
52
|
+
class Tree; end
|
|
53
|
+
|
|
54
|
+
it "invokes super #initialize" do
|
|
55
|
+
m = subject[:mammal]
|
|
56
|
+
m.temp.should == 98.6
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
context "subclass has default #initialize" do
|
|
60
|
+
class Cat < Mammal
|
|
61
|
+
construct_with :fur
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "invokes superclass #initialize" do
|
|
65
|
+
subject[:cat].temp.should == 98.6
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
context "subclass has 1-arg #initialize that invokes #super" do
|
|
70
|
+
class Ape < Mammal
|
|
71
|
+
construct_with :fur,:tree
|
|
72
|
+
attr_accessor :got_map
|
|
73
|
+
def initialize(map)
|
|
74
|
+
@got_map = map
|
|
75
|
+
super
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
let(:chauncy) { subject[:ape] }
|
|
80
|
+
|
|
81
|
+
it "invokes subclass custom #initialize with component map" do
|
|
82
|
+
fur = subject[:fur]
|
|
83
|
+
tree = subject[:tree]
|
|
84
|
+
chauncy.got_map.should == { fur: fur, tree: tree }
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it "invokes superclass #initialize" do
|
|
88
|
+
chauncy.temp.should == 98.6
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
context "subclass has 0-arg #initialize that invokes #super" do
|
|
93
|
+
class Dog < Mammal
|
|
94
|
+
construct_with :fur
|
|
95
|
+
attr_accessor :legs
|
|
96
|
+
def initialize
|
|
97
|
+
@legs = 4
|
|
98
|
+
super :whoa_there # superclass has a Conjected #initialize which requires the component map arg, though it's not used. Ugh.
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
let(:indy) { subject[:dog] }
|
|
103
|
+
|
|
104
|
+
it "invokes subclass #initialize" do
|
|
105
|
+
indy.legs.should == 4
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
it "invokes superclass #initialize" do
|
|
109
|
+
indy.temp.should == 98.6
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
context "subclass has a no-arg #initialize that does NOT invoke #super" do
|
|
114
|
+
class Shrew < Mammal
|
|
115
|
+
construct_with :fur
|
|
116
|
+
def initialize
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
it "does not invoke superclass #initiailize" do
|
|
121
|
+
subject[:shrew].temp.should be_nil
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
context "subclass has a 1-arg #initialize that does NOT invoke #super" do
|
|
126
|
+
class Shrew < Mammal
|
|
127
|
+
construct_with :fur
|
|
128
|
+
def initialize(map)
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
it "does not invoke superclass #initiailize" do
|
|
133
|
+
subject[:shrew].temp.should be_nil
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
context "superclass has 1-arg #initialize" do
|
|
144
|
+
class Reptile
|
|
145
|
+
construct_with :scales
|
|
146
|
+
attr_reader :super_map
|
|
147
|
+
def initialize(map)
|
|
148
|
+
@super_map = map
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
class Scales; end
|
|
153
|
+
class Rock; end
|
|
154
|
+
class Shell; end
|
|
155
|
+
|
|
156
|
+
it "invokes super #initialize with component map" do
|
|
157
|
+
subject[:reptile].super_map.should == { scales: subject[:scales] }
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
context "subclass has default #initialize" do
|
|
161
|
+
class Snake < Reptile
|
|
162
|
+
construct_with :scales
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
it "invokes superclass #initialize" do
|
|
166
|
+
subject[:reptile].super_map.should == { scales: subject[:scales] }
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
context "subclass has 1-arg #initialize that invokes #super" do
|
|
171
|
+
class Lizard < Reptile
|
|
172
|
+
construct_with :scales,:rock
|
|
173
|
+
attr_accessor :got_map
|
|
174
|
+
def initialize(map)
|
|
175
|
+
@got_map = map
|
|
176
|
+
super
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
let(:harry) { subject[:lizard] }
|
|
181
|
+
|
|
182
|
+
it "invokes subclass custom #initialize with component map" do
|
|
183
|
+
scales = subject[:scales]
|
|
184
|
+
rock = subject[:rock]
|
|
185
|
+
harry.got_map.should == { scales: scales, rock: rock }
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
it "invokes superclass #initialize with component_map" do
|
|
189
|
+
scales = subject[:scales]
|
|
190
|
+
rock = subject[:rock]
|
|
191
|
+
harry.super_map.should == { scales: scales, rock: rock }
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
#
|
|
196
|
+
# This case--where a subclass has a user-defined #initialize, which does
|
|
197
|
+
# not accept an argument (will not be passed the component map at construct time)
|
|
198
|
+
# invokes super with some bs argument because we CANNOT SUPPLY super with its
|
|
199
|
+
# needs. User SHOULD accept the component_map as an argument to #initialize
|
|
200
|
+
# and let the map float to super class.
|
|
201
|
+
#
|
|
202
|
+
context "subclass has 0-arg #initialize that invokes #super" do
|
|
203
|
+
class Turtle < Reptile
|
|
204
|
+
construct_with :scales, :shell
|
|
205
|
+
attr_accessor :tail
|
|
206
|
+
def initialize
|
|
207
|
+
@tail = true
|
|
208
|
+
super :theres_ur_problem # stoopid
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
let(:franklin) { subject[:turtle] }
|
|
213
|
+
|
|
214
|
+
it "invokes subclass #initialize" do
|
|
215
|
+
franklin.tail.should == true
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
it "invokes superclass #initialize with... fuh..." do
|
|
219
|
+
franklin.super_map.should == :theres_ur_problem
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
context "subclass has a no-arg #initialize that does NOT invoke #super" do
|
|
224
|
+
class Aligator < Reptile
|
|
225
|
+
construct_with :scales
|
|
226
|
+
def initialize
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
it "does not invoke superclass #initiailize" do
|
|
231
|
+
subject[:aligator].super_map.should be_nil
|
|
232
|
+
end
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
context "subclass has a 1-arg #initialize that does NOT invoke #super" do
|
|
236
|
+
class Croc < Reptile
|
|
237
|
+
construct_with :scales
|
|
238
|
+
attr_reader :my_map
|
|
239
|
+
def initialize(map)
|
|
240
|
+
@my_map = map
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
it "does not invoke superclass #initiailize" do
|
|
245
|
+
subject[:croc].super_map.should be_nil
|
|
246
|
+
subject[:croc].my_map.should == { scales: subject[:scales] }
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
end
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
end
|
|
253
|
+
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
2
2
|
|
|
3
3
|
describe "object referencing its own context" do
|
|
4
|
-
subject { Conject.
|
|
4
|
+
subject { Conject.create_object_context(nil) }
|
|
5
5
|
|
|
6
6
|
before do
|
|
7
7
|
append_test_load_path "basic_composition"
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
3
3
|
|
|
4
4
|
describe "nested contexts" do
|
|
5
|
-
subject { Conject.
|
|
5
|
+
subject { Conject.create_object_context(nil) }
|
|
6
6
|
|
|
7
|
-
let(:root_context) {
|
|
7
|
+
let(:root_context) { subject }
|
|
8
8
|
|
|
9
9
|
before do
|
|
10
10
|
append_test_load_path "basic_composition"
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: conject
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.4
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,11 +9,11 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-
|
|
12
|
+
date: 2012-03-14 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rake
|
|
16
|
-
requirement: &
|
|
16
|
+
requirement: &2152782340 !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
19
19
|
- - ! '>='
|
|
@@ -21,10 +21,10 @@ dependencies:
|
|
|
21
21
|
version: '0'
|
|
22
22
|
type: :development
|
|
23
23
|
prerelease: false
|
|
24
|
-
version_requirements: *
|
|
24
|
+
version_requirements: *2152782340
|
|
25
25
|
- !ruby/object:Gem::Dependency
|
|
26
26
|
name: rspec
|
|
27
|
-
requirement: &
|
|
27
|
+
requirement: &2152781820 !ruby/object:Gem::Requirement
|
|
28
28
|
none: false
|
|
29
29
|
requirements:
|
|
30
30
|
- - ! '>='
|
|
@@ -32,10 +32,10 @@ dependencies:
|
|
|
32
32
|
version: '0'
|
|
33
33
|
type: :development
|
|
34
34
|
prerelease: false
|
|
35
|
-
version_requirements: *
|
|
35
|
+
version_requirements: *2152781820
|
|
36
36
|
- !ruby/object:Gem::Dependency
|
|
37
37
|
name: simplecov
|
|
38
|
-
requirement: &
|
|
38
|
+
requirement: &2152781320 !ruby/object:Gem::Requirement
|
|
39
39
|
none: false
|
|
40
40
|
requirements:
|
|
41
41
|
- - ! '>='
|
|
@@ -43,7 +43,7 @@ dependencies:
|
|
|
43
43
|
version: '0'
|
|
44
44
|
type: :development
|
|
45
45
|
prerelease: false
|
|
46
|
-
version_requirements: *
|
|
46
|
+
version_requirements: *2152781320
|
|
47
47
|
description: Enable Guice-like dependency injection and contextual object interactions.
|
|
48
48
|
email:
|
|
49
49
|
- david.crosby@atomicobject.com
|
|
@@ -60,6 +60,7 @@ files:
|
|
|
60
60
|
- Rakefile
|
|
61
61
|
- TODO
|
|
62
62
|
- conject.gemspec
|
|
63
|
+
- doc/inheritance_woes.txt
|
|
63
64
|
- lib/conject.rb
|
|
64
65
|
- lib/conject/borrowed_active_support_inflector.rb
|
|
65
66
|
- lib/conject/class_ext_construct_with.rb
|
|
@@ -77,6 +78,7 @@ files:
|
|
|
77
78
|
- spec/acceptance/regression/README
|
|
78
79
|
- spec/acceptance/regression/basic_composition_spec.rb
|
|
79
80
|
- spec/acceptance/regression/basic_object_creation_spec.rb
|
|
81
|
+
- spec/acceptance/regression/inherited_dependencies_spec.rb
|
|
80
82
|
- spec/acceptance/regression/inject_object_context_spec.rb
|
|
81
83
|
- spec/acceptance/regression/nested_contexts_spec.rb
|
|
82
84
|
- spec/conject/borrowed_active_support_inflector_spec.rb
|
|
@@ -91,6 +93,7 @@ files:
|
|
|
91
93
|
- spec/conject/utilities_spec.rb
|
|
92
94
|
- spec/spec_helper.rb
|
|
93
95
|
- spec/support/SPEC_HELPERS_GO_HERE
|
|
96
|
+
- spec/support/conject_helpers.rb
|
|
94
97
|
- spec/support/load_path_helpers.rb
|
|
95
98
|
- spec/test_data/basic_composition/fence.rb
|
|
96
99
|
- spec/test_data/basic_composition/front_desk.rb
|
|
@@ -99,8 +102,16 @@ files:
|
|
|
99
102
|
- spec/test_data/basic_composition/lobby.rb
|
|
100
103
|
- spec/test_data/basic_composition/master_of_puppets.rb
|
|
101
104
|
- spec/test_data/basic_composition/nails.rb
|
|
105
|
+
- spec/test_data/basic_composition/special_guest.rb
|
|
102
106
|
- spec/test_data/basic_composition/tv.rb
|
|
107
|
+
- spec/test_data/basic_composition/very_special_guest.rb
|
|
103
108
|
- spec/test_data/basic_composition/wood.rb
|
|
109
|
+
- spec/test_data/inheritance/body.rb
|
|
110
|
+
- spec/test_data/inheritance/car.rb
|
|
111
|
+
- spec/test_data/inheritance/emblem.rb
|
|
112
|
+
- spec/test_data/inheritance/malibu.rb
|
|
113
|
+
- spec/test_data/inheritance/vehicle.rb
|
|
114
|
+
- spec/test_data/inheritance/wheel.rb
|
|
104
115
|
- spec/test_data/simple_stuff/some_random_class.rb
|
|
105
116
|
- spike/arity_funny_business_in_different_ruby_versions.rb
|
|
106
117
|
- spike/depends_on_spike.rb
|
|
@@ -133,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
133
144
|
version: '0'
|
|
134
145
|
requirements: []
|
|
135
146
|
rubyforge_project:
|
|
136
|
-
rubygems_version: 1.8.
|
|
147
|
+
rubygems_version: 1.8.15
|
|
137
148
|
signing_key:
|
|
138
149
|
specification_version: 3
|
|
139
150
|
summary: Enable Guice-like dependency injection and contextual object interactions.
|
|
@@ -142,6 +153,7 @@ test_files:
|
|
|
142
153
|
- spec/acceptance/regression/README
|
|
143
154
|
- spec/acceptance/regression/basic_composition_spec.rb
|
|
144
155
|
- spec/acceptance/regression/basic_object_creation_spec.rb
|
|
156
|
+
- spec/acceptance/regression/inherited_dependencies_spec.rb
|
|
145
157
|
- spec/acceptance/regression/inject_object_context_spec.rb
|
|
146
158
|
- spec/acceptance/regression/nested_contexts_spec.rb
|
|
147
159
|
- spec/conject/borrowed_active_support_inflector_spec.rb
|
|
@@ -156,6 +168,7 @@ test_files:
|
|
|
156
168
|
- spec/conject/utilities_spec.rb
|
|
157
169
|
- spec/spec_helper.rb
|
|
158
170
|
- spec/support/SPEC_HELPERS_GO_HERE
|
|
171
|
+
- spec/support/conject_helpers.rb
|
|
159
172
|
- spec/support/load_path_helpers.rb
|
|
160
173
|
- spec/test_data/basic_composition/fence.rb
|
|
161
174
|
- spec/test_data/basic_composition/front_desk.rb
|
|
@@ -164,6 +177,14 @@ test_files:
|
|
|
164
177
|
- spec/test_data/basic_composition/lobby.rb
|
|
165
178
|
- spec/test_data/basic_composition/master_of_puppets.rb
|
|
166
179
|
- spec/test_data/basic_composition/nails.rb
|
|
180
|
+
- spec/test_data/basic_composition/special_guest.rb
|
|
167
181
|
- spec/test_data/basic_composition/tv.rb
|
|
182
|
+
- spec/test_data/basic_composition/very_special_guest.rb
|
|
168
183
|
- spec/test_data/basic_composition/wood.rb
|
|
184
|
+
- spec/test_data/inheritance/body.rb
|
|
185
|
+
- spec/test_data/inheritance/car.rb
|
|
186
|
+
- spec/test_data/inheritance/emblem.rb
|
|
187
|
+
- spec/test_data/inheritance/malibu.rb
|
|
188
|
+
- spec/test_data/inheritance/vehicle.rb
|
|
189
|
+
- spec/test_data/inheritance/wheel.rb
|
|
169
190
|
- spec/test_data/simple_stuff/some_random_class.rb
|