activerecord-collections 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a957127ae2a21f3a1b1d86589127c32b61ea74ec
4
- data.tar.gz: ea061b5fa0357a66cd1f93d63332b297d25ac8f9
3
+ metadata.gz: 22ce528f513350381a68417cd1b739ddca67c5c4
4
+ data.tar.gz: ec7a642f1a23c4dfc41cf1ae7f059c263be993c1
5
5
  SHA512:
6
- metadata.gz: 9b05f147793bc3239373ef8c0ecc232650f6e8972d1ee7d98942f1259904e0b3451caf3c45422dae6167ecef2708968e06d7a80a0b8e5f7904aaf98a0c52038f
7
- data.tar.gz: ea45a2d8364d10f0c1d9a998ca9a372db81ab7098fc39ceffc71cc2732491891bf673270cea2c8fb0358e9f7a8bc5b98bfcd36d742ea8f35ac21d865ab4c4e6e
6
+ metadata.gz: e3965879d213c235ddc447ec1a9d723736af7509aebf7fe4d4749e96a951a4213e1cedadf9dec7acc82035d7ec80b30088db75cc924f95eb91c14519d6d46b1b
7
+ data.tar.gz: 32445dbdd55347fe201dca00bc1effe2618356e6f3d616f15197d364c925414a34433b42e5d2bdb48934801e4350f52a6693f0423ee9226cc9d6673c486eaca3
@@ -53,7 +53,7 @@ module ActiveRecord
53
53
  protected
54
54
 
55
55
  def initialize(*criteria)
56
- if criteria.first.present? && criteria.first.ancestors.include?(ActiveRecord::Base)
56
+ if criteria.first.present? && criteria.first.respond_to?(:ancestors) && criteria.first.ancestors.include?(ActiveRecord::Base)
57
57
  @collectable = criteria.slice!(0)
58
58
  end
59
59
 
@@ -8,7 +8,14 @@ module ActiveRecord
8
8
  end
9
9
 
10
10
  def kollektion
11
- @collection_class || ActiveRecord::Collection.collections.to_a.select { |c| c.collectable == self }.first || ActiveRecord::Collection
11
+ plural_klass = begin
12
+ pklass = self.name.pluralize.constantize
13
+ raise "Not an ActiveRecord::Collection" unless pklass.ancestors.include?(ActiveRecord::Collection)
14
+ pklass
15
+ rescue
16
+ nil
17
+ end
18
+ @collection_class || ActiveRecord::Collection.collections.to_a.select { |c| c.collectable == self }.first || plural_klass || ActiveRecord::Collection
12
19
  end
13
20
 
14
21
  def collection(*criteria)
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module Collections
3
- VERSION = '0.0.9'
3
+ VERSION = '0.0.10'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-collections
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Rebec