acts_has_many 0.3.2 → 0.3.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 899f42f7868ed45b0eb22bdd0e56d3cf4a2385af
4
- data.tar.gz: 95a0effdaf788f947e92fabea3dec9e7a51e219d
3
+ metadata.gz: 3aa095755b90aefdb28587878e146f1ea3eacf8e
4
+ data.tar.gz: 227dc4fdf96925104ecaf2fab57613504460dfd1
5
5
  SHA512:
6
- metadata.gz: 724009b91d5dee328d7eca99829c8212a31a778f29132cad80aa0f6aebbf4bb3e501e204213faffdcf7cd05ffd12658ee94345d8c60bf1debc24b597dbd29436
7
- data.tar.gz: bb297b2056cd2f77a74ef544daf0bea950fd4781a3b49b92cc27b858812f15728ff303d251b98fd4e07a4d1763a4874f851687689fda06e3a82aee2d2e4cfd5b
6
+ metadata.gz: 64141545c61c2b3db1b914832f2552205dfe7c751e18a28e122dd25ecf7d0889f0561ad8b2016f3e228bc9def24f268a81044b8ac33f0ce077433b7602ce5ee1
7
+ data.tar.gz: bf3c4c673ab9dc71ad749730478d8459f5b9459f8130c44d4d7b5f4df5a40995b7781422ff3484a60b5feb77368c60faf47f6bd76f57686006301ffa3e34787e
data/.travis.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  language: ruby
2
2
  rvm:
3
- - "1.9.3"
3
+ - "2.0.0"
data/Gemfile CHANGED
File without changes
data/LICENSE CHANGED
File without changes
data/README.md CHANGED
@@ -24,7 +24,8 @@ Or install it yourself as:
24
24
  3. Should use `dependent: :destroy`
25
25
 
26
26
  4. If only `acts_has_many` is used:
27
- ```ruby
27
+
28
+ ```ruby
28
29
  class Posting < ActiveRecord::Base
29
30
  belongs_to :tag, dependent: :destroy
30
31
  end
@@ -34,42 +35,53 @@ Or install it yourself as:
34
35
 
35
36
  acts_has_many :postings
36
37
  end
37
- ```
38
- In this case you have `has_many_update` method:
39
- ```ruby
40
- new_record, delete_record = Tag.first.has_many_update {title: 'ruby'}
41
- ```
42
- if you use `acts_has_many` with `through: true` parameters:
43
- ```ruby
44
- new_records, delete_ids = Tag.has_many_through_update(update: data, new: date)
45
- ```
38
+ ```
39
+
40
+ In this case you have `has_many_update` method:
41
+
42
+ ```ruby
43
+ new_record, delete_record = Tag.first.has_many_update {title: 'ruby'}
44
+ ```
45
+
46
+ if you use `acts_has_many` with `through: true` parameters:
47
+
48
+ ```ruby
49
+ new_records, delete_ids = Tag.has_many_through_update(update: data, new: date)
50
+ ```
46
51
 
47
52
  5. If you use `acts_has_many` with `acts_has_many_for`
48
- ```ruby
49
- class Posting < ActiveRecord::Base
50
- belongs_to :tag, dependent: :destroy
51
53
 
52
- acts_has_many_for :tag
53
- end
54
+ ```ruby
55
+ class Posting < ActiveRecord::Base
56
+ belongs_to :tag, dependent: :destroy
54
57
 
55
- class Tag < ActiveRecord::Base
56
- has_many :postings
58
+ acts_has_many_for :tag
59
+ end
57
60
 
58
- acts_has_many :postings
59
- end
60
- ```
61
- In this case you can use the same that is in 4-th point and also:
62
- ```ruby
63
- Posting.first.tag_attributes = {title: 'ruby'}
64
- ```
65
- if you use `acts_has_many` with `through: true` parameters
66
- ```ruby
67
- Posting.first.tags_collection = [{title: 'ruby'}, {title: 'python'}]
68
- ```
61
+ class Tag < ActiveRecord::Base
62
+ has_many :postings
63
+
64
+ acts_has_many :postings
65
+ end
66
+ ```
67
+
68
+ In this case you can use the same that is in 4-th point and also:
69
+
70
+ ```ruby
71
+ Posting.first.tag_attributes = {title: 'ruby'}
72
+ ```
73
+
74
+ if you use `acts_has_many` with `through: true` parameters
75
+
76
+ ```ruby
77
+ Posting.first.tags_collection = [{title: 'ruby'}, {title: 'python'}]
78
+ ```
69
79
 
70
80
  New in v0.3.2
71
81
  --------------
82
+
72
83
  Use `block` to change condition, default search is `where :compare => :value`
84
+
73
85
  ```ruby
74
86
  class Tag < ActiveRecord::Base
75
87
  has_many :postings
@@ -79,6 +91,7 @@ Use `block` to change condition, default search is `where :compare => :value`
79
91
  end
80
92
  end
81
93
  ```
94
+
82
95
  Replace `compare` method to `condition`
83
96
 
84
97
  Notice, if block is defined:
@@ -88,6 +101,7 @@ Notice, if block is defined:
88
101
 
89
102
  More
90
103
  ----
104
+
91
105
  `acts_has_many` options:
92
106
  >* list relations or after necessary relations
93
107
  >* :compare( string or symbol; default: :title) - name column with unique elements in table
@@ -120,6 +134,7 @@ More
120
134
  Examples
121
135
  --------
122
136
  Use with `has_manay`:
137
+
123
138
  ```ruby
124
139
  class Posting < ActiveRecord::Base
125
140
  belongs_to :tag, dependent: :destroy
@@ -155,7 +170,9 @@ Use with `has_manay`:
155
170
 
156
171
  Tag.all # => [#<Tag id: 1, title: "ruby">]
157
172
  ```
173
+
158
174
  Use with `has_many :through`
175
+
159
176
  ```ruby
160
177
  class Posting < ActiveRecord::Base
161
178
  has_many :posting_tags, dependent: :destroy
@@ -205,6 +222,7 @@ Use with `has_many :through`
205
222
 
206
223
  Contributing
207
224
  ------------
225
+
208
226
  You can help improve this project.
209
227
 
210
228
  Here are some ways *you* can contribute:
@@ -221,6 +239,7 @@ Here are some ways *you* can contribute:
221
239
 
222
240
  Submitting an Issue
223
241
  -------------------
242
+
224
243
  We use the [GitHub issue tracker](https://github.com/igor04/acts_has_many/issues) to track bugs and
225
244
  features. Before submitting a bug report or feature request, check to make sure it hasn't already
226
245
  been submitted. You can indicate support for an existing issuse by voting it up. When submitting a
data/Rakefile CHANGED
File without changes
@@ -18,10 +18,10 @@ Gem::Specification.new do |gem|
18
18
  gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  gem.require_paths = ['lib']
20
20
 
21
- gem.add_development_dependency 'bundler'
22
- gem.add_development_dependency 'rake'
23
- gem.add_development_dependency 'rspec'
24
- gem.add_development_dependency 'sqlite3'
25
- gem.add_development_dependency 'activerecord'
21
+ gem.add_development_dependency 'bundler', '~> 1.5'
22
+ gem.add_development_dependency 'rake', '~> 10'
23
+ gem.add_development_dependency 'rspec', '~> 2.14'
24
+ gem.add_development_dependency 'sqlite3', '~> 1.3'
25
+ gem.add_development_dependency 'activerecord', '~> 3.2'
26
26
  end
27
27
 
data/init.rb CHANGED
File without changes
@@ -27,8 +27,7 @@ module ActiveRecord
27
27
  def actual? exclude = true
28
28
  actual = 0
29
29
  self.class.dependent_relations.each do |dependent_relation|
30
- tmp = self.send dependent_relation
31
- actual += tmp.all.size
30
+ actual += self.send(dependent_relation).all.size
32
31
  end
33
32
 
34
33
  exclude ? actual > 1 : actual > 0
@@ -36,7 +36,7 @@ module ActiveRecord
36
36
  def #{relation}_collection= data
37
37
  self.tmp_garbage ||= {}
38
38
 
39
- if data.is_a? Array
39
+ if data.is_a?(Array) || data.is_a?(ActiveRecord::Relation)
40
40
  if data.first.is_a? Hash
41
41
  new, del = #{relation.classify}.has_many_through_update new: data
42
42
  elsif data.first.is_a? #{relation.classify}
File without changes
@@ -1,3 +1,3 @@
1
1
  module ActsHasMany
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
data/lib/acts_has_many.rb CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
data/spec/helper.rb CHANGED
File without changes
metadata CHANGED
@@ -1,85 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_has_many
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor IS04
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-05 00:00:00.000000000 Z
11
+ date: 2014-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '1.5'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '1.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '10'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '10'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '2.14'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '2.14'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: sqlite3
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '1.3'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '1.3'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: activerecord
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '3.2'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ~>
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: '3.2'
83
83
  description: This gem gives functional for update elements has_many relation
84
84
  email: igor.s04g@gmail.com
85
85
  executables: []
@@ -122,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  version: '0'
123
123
  requirements: []
124
124
  rubyforge_project:
125
- rubygems_version: 2.0.0
125
+ rubygems_version: 2.0.14
126
126
  signing_key:
127
127
  specification_version: 4
128
128
  summary: All records must be used, otherwise they will be deleted. Clear logic with