fixjour 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -1,6 +1,6 @@
1
1
  module Fixjour
2
2
  def self.included(klass)
3
- klass.extend(RedundancyChecker)
3
+ klass.extend(RedundancyChecker) unless Fixjour.allow_redundancy?
4
4
  end
5
5
 
6
6
  # Uses method_added hook to make sure no redundant builder methods
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fixjour
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pat Nakajima