deals_with 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,17 +27,18 @@ module DealsWith
27
27
 
28
28
 
29
29
  def generate_resource_methods(model_name)
30
+ short_name = model_name.gsub(/.+[:]{2}/, '')
30
31
  class_eval %{
31
- def #{model_name.tableize}
32
- @#{model_name.tableize} ||=
32
+ def #{short_name.tableize}
33
+ @#{short_name.tableize} ||=
33
34
  self.class.deals_with_models[#{model_name.inspect}].all(self)
34
35
  end
35
- def #{model_name.underscore}
36
- @#{model_name.underscore} ||=
36
+ def #{short_name.underscore}
37
+ @#{short_name.underscore} ||=
37
38
  self.class.deals_with_models[#{model_name.inspect}].find(self)
38
39
  end
39
- def build_#{model_name.underscore}
40
- @#{model_name.underscore} ||=
40
+ def build_#{short_name.underscore}
41
+ @#{short_name.underscore} ||=
41
42
  self.class.deals_with_models[#{model_name.inspect}].build(self)
42
43
  end
43
44
  }
@@ -33,7 +33,7 @@ module DealsWith
33
33
  end
34
34
 
35
35
  def primary_for(controller)
36
- controller_class.to_s.include? "#{model_name.pluralize}_controller".classify
36
+ controller_class.to_s.include? "#{model_name.gsub(/.+[:]{2}/, '').pluralize}_controller".classify
37
37
  end
38
38
 
39
39
  def base(controller)
@@ -55,7 +55,7 @@ module DealsWith
55
55
  if @options[:find_param]
56
56
  @find_param_key = @options[:find_param]
57
57
  else
58
- @find_param_key = "#{model_name.underscore}_id"
58
+ @find_param_key = "#{model_name.gsub(/.+[:]{2}/, '').underscore}_id"
59
59
  @find_param_key = 'id' if primary_for(controller)
60
60
  end
61
61
  @find_param_key
@@ -69,7 +69,7 @@ module DealsWith
69
69
  @build_param_key ||= if @options[:build_param]
70
70
  @options[:build_param]
71
71
  else
72
- "#{model_name.underscore}"
72
+ model_name.gsub(/[:]{2}/, '').underscore
73
73
  end
74
74
  end
75
75
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deals_with
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Menke
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-26 00:00:00 +02:00
12
+ date: 2009-06-22 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies: []
15
15