fixjour 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/fixjour/builders.rb +13 -1
- data/lib/fixjour/merging_proxy.rb +1 -1
- data/lib/fixjour/redundant_check.rb +1 -1
- metadata +1 -1
data/lib/fixjour/builders.rb
CHANGED
@@ -8,6 +8,18 @@ module Fixjour
|
|
8
8
|
|
9
9
|
attr_accessor :allow_redundancy
|
10
10
|
|
11
|
+
def prohibit_redundancy!
|
12
|
+
@always_allow_redundancy = false
|
13
|
+
end
|
14
|
+
|
15
|
+
def allow_redundancy!
|
16
|
+
@always_allow_redundancy = true
|
17
|
+
end
|
18
|
+
|
19
|
+
def allow_redundancy?
|
20
|
+
@always_allow_redundancy || @allow_redundancy
|
21
|
+
end
|
22
|
+
|
11
23
|
# The list of classes that have builders defined.
|
12
24
|
def builders
|
13
25
|
@builders ||= Set.new
|
@@ -63,7 +75,7 @@ module Fixjour
|
|
63
75
|
# redundant builders aren't defined, which can lead to confusion
|
64
76
|
# when trying to figure out where objects are being created.
|
65
77
|
def add_builder(builder)
|
66
|
-
unless builders.add?(builder) or Fixjour.allow_redundancy
|
78
|
+
unless builders.add?(builder) or Fixjour.allow_redundancy?
|
67
79
|
raise RedundantBuilder.new("You already defined a builder for #{builder.klass.inspect}")
|
68
80
|
end
|
69
81
|
end
|
@@ -3,7 +3,7 @@ module Fixjour
|
|
3
3
|
# block takes two arguments. Automatically merges overrides when
|
4
4
|
# the #new method is called.
|
5
5
|
class MergingProxy
|
6
|
-
instance_methods.each { |m| undef_method(m) unless m =~ /__|inspect/ }
|
6
|
+
instance_methods.each { |m| undef_method(m) unless m =~ /__|inspect|object_id/ }
|
7
7
|
|
8
8
|
def initialize(klass, overrides)
|
9
9
|
@klass = klass
|