throughcheckboxes 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.
@@ -12,25 +12,21 @@ module ThroughCheckboxes
12
12
 
13
13
  ThroughCheckboxes::Core.validate(klass, *relations)
14
14
 
15
- for relation in relations
15
+ relations.each { |relation|
16
16
 
17
- field_name="#{relation}_ids"
17
+ field_name=ThroughCheckboxes::Core.field_name(relation)
18
18
 
19
- class_eval do
20
- attr_accessible field_name.to_sym
21
- end
19
+ attr_accessible field_name.to_sym
22
20
 
23
- instance_eval do
24
- define_method "#{field_name}=" do |ids|
25
- send("#{relation}=",ids.select { |id| id.present? }.map {|id| ThroughCheckboxes::Core.relation_klass(klass, relation).find(id)})
26
- end
21
+ define_method "#{field_name}=" do |ids|
22
+ send("#{relation}=",ids.select { |id| id.present? }.map {|id| ThroughCheckboxes::Core.relation_klass(klass, relation).find(id)})
23
+ end
27
24
 
28
- define_method field_name do
29
- send("#{relation}").map {|e| e.id}
30
- end
25
+ define_method field_name do
26
+ send("#{relation}").map {|e| e.id}
31
27
  end
32
28
 
33
- end
29
+ }
34
30
 
35
31
  end
36
32
 
@@ -20,6 +20,10 @@ module ThroughCheckboxes
20
20
  relation_klass.classify.constantize
21
21
  end
22
22
 
23
+ def self.field_name(relation)
24
+ "#{relation}_ids"
25
+ end
26
+
23
27
 
24
28
  end
25
29
 
@@ -1,3 +1,3 @@
1
1
  module Throughcheckboxes
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: throughcheckboxes
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 3
9
- version: 0.0.3
4
+ prerelease:
5
+ version: 0.0.4
10
6
  platform: ruby
11
7
  authors:
12
8
  - lucapette
@@ -14,7 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-03-11 00:00:00 +01:00
13
+ date: 2011-03-13 00:00:00 +01:00
18
14
  default_executable:
19
15
  dependencies: []
20
16
 
@@ -52,21 +48,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
52
48
  requirements:
53
49
  - - ">="
54
50
  - !ruby/object:Gem::Version
55
- segments:
56
- - 0
57
51
  version: "0"
58
52
  required_rubygems_version: !ruby/object:Gem::Requirement
59
53
  none: false
60
54
  requirements:
61
55
  - - ">="
62
56
  - !ruby/object:Gem::Version
63
- segments:
64
- - 0
65
57
  version: "0"
66
58
  requirements: []
67
59
 
68
60
  rubyforge_project: throughcheckboxes
69
- rubygems_version: 1.3.7
61
+ rubygems_version: 1.5.2
70
62
  signing_key:
71
63
  specification_version: 3
72
64
  summary: This gem will handle has_many :through association with checkboxes