sequel_polymorphic 0.2.1 → 0.2.2

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: 296fe1ecc60ded36fb9747c54c886bda83afc24d
4
- data.tar.gz: a20d91dd5237f8ba992ec910fbb5f2cc0c975947
3
+ metadata.gz: 58157571be86e9246c399eb573e4a7d8e1bca04f
4
+ data.tar.gz: 4507cd3a9daec3bebca3fa2523f1919ee01255bb
5
5
  SHA512:
6
- metadata.gz: 61c2cb72f1852a67ebf6689e9d9042ea80e24635a653cd5b0c51d02ee56fb22e6e280b6b2e24e15956099d091553cbeb418c1747b8bcdeae1dc1dd47541af5c5
7
- data.tar.gz: 4e3fda43551679a74fd2170b3c93d8c268f0e48a560c4ec599f1a65a420e90696e45081c3b9236732fce8074f78fcfc8fcce2a054583bd00ebf93678e7a3da5c
6
+ metadata.gz: 5de6bb6bbe1696dddb2b208f834aabc7c7f7019a2aaafbb7ae5a462a91f69df15f8bd52603aa0ea9c0dd13c0caa0899c5628be449c9f7f9b9d4cdf07f9b052f0
7
+ data.tar.gz: 75b40c41d1e09cc14fcff7ec602e7ce0168f1d8871af6b094cd1b130461ea8fe12e4d3af85fa06ea0c6fbb506dc402ae39f0c235ceb815ec91ed42dbb371f2f1
@@ -17,7 +17,7 @@ module Sequel
17
17
  options ||= {}
18
18
 
19
19
  if options[:polymorphic]
20
- model = self.to_s.downcase # comment
20
+ model = underscore(self.to_s) # comment
21
21
  plural_model = pluralize(model) # comments
22
22
 
23
23
  associate(:many_to_one, able,
@@ -31,7 +31,7 @@ module Sequel
31
31
  able_type = send(:"#{able}_type")
32
32
  able_id = send(:"#{able}_id")
33
33
  return if able_type.nil? || able_id.nil?
34
- klass = self.class.send(:constantize, able_type.capitalize)
34
+ klass = self.class.send(:constantize, able_type)
35
35
  klass.where(klass.primary_key => able_id)
36
36
  end),
37
37
  :eager_loader => (proc do |eo|
@@ -43,7 +43,7 @@ module Sequel
43
43
  ((id_map[model_able_type] ||= {})[model_able_id] ||= []) << model if !model_able_type.nil? && !model_able_id.nil?
44
44
  end
45
45
  id_map.each do |klass_name, id_map|
46
- klass = constantize(klass_name.capitalize)
46
+ klass = constantize(camelize(klass_name))
47
47
  klass.where(klass.primary_key=>id_map.keys).all do |related_obj|
48
48
  id_map[related_obj.pk].each do |model|
49
49
  model.associations[able] = related_obj
@@ -101,7 +101,7 @@ module Sequel
101
101
  able_type = :"#{able}_type"
102
102
  collection_singular = singularize(collection_name.to_s).to_sym # => tag
103
103
  collection_singular_id = :"#{collection_singular}_id"
104
- through_klass = constantize(singularize(through.to_s).capitalize) # => Tagging
104
+ through_klass = constantize(singularize(camelize(through.to_s))) # => Tagging
105
105
 
106
106
  associate(:many_to_many, collection_name,
107
107
  :left_key => able_id,
@@ -2,7 +2,7 @@ module Sequel
2
2
  module Plugins
3
3
  module Polymorphic
4
4
 
5
- VERSION = '0.2.1'
5
+ VERSION = '0.2.2'
6
6
 
7
7
  end # Polymorphic
8
8
  end # Plugins
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel_polymorphic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jack Dempsey
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-08-04 00:00:00.000000000 Z
13
+ date: 2015-08-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: sequel