fixjour 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/fixjour/redundant_check.rb +8 -3
  2. metadata +1 -1
@@ -15,17 +15,22 @@ module Fixjour
15
15
  end
16
16
 
17
17
  module RedundancyChecker
18
- BUILDER_METHOD_PATTERN = /(new|create|valid)_([a-zA-Z0-9]+)(_attributes)?/
18
+ BUILDER_METHOD_PATTERN = /^(new|create|valid)_(\w+)(_attributes)?$/
19
19
 
20
20
  def method_added(sym)
21
21
  name = sym.to_s
22
22
 
23
- if match = name.match(BUILDER_METHOD_PATTERN)
24
- klass_name = match[2].classify
23
+ if klass_name = get_klass_name(name)
25
24
  if Fixjour.builder_defined?(klass_name)
26
25
  raise RedundantBuilder.new("You already defined a builder for #{inspect}")
27
26
  end
28
27
  end
29
28
  end
29
+
30
+ def get_klass_name(name)
31
+ if match = name.match(BUILDER_METHOD_PATTERN)
32
+ match[2].classify.gsub(/Attribute$/, '')
33
+ end
34
+ end
30
35
  end
31
36
  end
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.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pat Nakajima