through_hierarchy 0.1.5 → 0.2.0

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
- SHA1:
3
- metadata.gz: f3bc6c2921451d1379f51c422e11ef87fb7ba934
4
- data.tar.gz: 737084656d7148d237c1dee59f17290fc84a7e27
2
+ SHA256:
3
+ metadata.gz: ed01a12faf0874f494e1622e5b4810c8195438a0a962032cbb49383e2d86e513
4
+ data.tar.gz: 11213859736477129737b3b026f4c689b37086a900a950a8bd853d4d127198a5
5
5
  SHA512:
6
- metadata.gz: 36241a8007d284967306a4ce63cc6ff5de5624e3950e4c88534b9b47292a851cc6182ac2574f36333c0c5f8f74e28c0a95f123aac3b7bea2e33921caa471b463
7
- data.tar.gz: 7feba64bceb116fbd151b7bc2b0562931bcc43ca96260d82cf5d056bedad1f1057e5530d47100bcedffb82ab9f233ae48ef524053a364dd78eb338609f7927ec
6
+ metadata.gz: 6a7ab21447264d5170415108931fed9ef426b9bdb9302c92af2e0385231b41d3690b541453061aa35b319b5d3aae8fb6b08f3216b876f598324c517cc4b000a6
7
+ data.tar.gz: e044a87e25e344be7979ccc38e96a98ac7ba88aaac000ac78882aec2b087ff9a395d0b24d95fcae6e3fb7ecf247d7bb884463305ba59b35288bda29ba1ca09fa
@@ -6,6 +6,7 @@ require 'through_hierarchy/associations/has_one.rb'
6
6
  require 'through_hierarchy/associations/has_many.rb'
7
7
  require 'through_hierarchy/associations/has_uniq.rb'
8
8
  require 'through_hierarchy/exceptions.rb'
9
+ require 'through_hierarchy/rails_utils.rb'
9
10
  require 'through_hierarchy/hierarchicals/hierarchical.rb'
10
11
  require 'through_hierarchy/hierarchicals/instance.rb'
11
12
 
@@ -60,7 +60,7 @@ module ThroughHierarchy
60
60
  Arel.sql(
61
61
  "CASE `#{@source.name}`.`#{foreign_type_name}` " +
62
62
  hierarchy_models.map.with_index do |model, ii|
63
- "WHEN #{model.sanitize(model.base_class.to_s)} THEN #{ii} "
63
+ "WHEN #{ThroughHierarchy::RailsUtils.sanitize_sql(model.base_class.to_s)} THEN #{ii} "
64
64
  end.join +
65
65
  "END"
66
66
  )
@@ -160,4 +160,4 @@ module ThroughHierarchy
160
160
 
161
161
  end
162
162
  end
163
- end
163
+ end
@@ -0,0 +1,17 @@
1
+ module ThroughHierarchy
2
+ module RailsUtils
3
+ module_function
4
+
5
+ def sanitize_sql(string)
6
+ if rails_major_minor_version < 5.1
7
+ ActiveRecord::Base.sanitize(string)
8
+ else
9
+ ActiveRecord::Base.sanitize_sql_array(["?", string])
10
+ end
11
+ end
12
+
13
+ def rails_major_minor_version
14
+ Rails.version.split(".").first(2).join(".").to_f
15
+ end
16
+ end
17
+ end
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: through_hierarchy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Schwartz
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2016-05-04 00:00:00.000000000 Z
@@ -27,11 +27,12 @@ files:
27
27
  - lib/through_hierarchy/hierarchicals/hierarchical.rb
28
28
  - lib/through_hierarchy/hierarchicals/instance.rb
29
29
  - lib/through_hierarchy/hierarchy.rb
30
+ - lib/through_hierarchy/rails_utils.rb
30
31
  homepage: https://github.com/ozydingo/through_hierarchy
31
32
  licenses:
32
33
  - MIT
33
34
  metadata: {}
34
- post_install_message:
35
+ post_install_message:
35
36
  rdoc_options: []
36
37
  require_paths:
37
38
  - lib
@@ -46,9 +47,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
46
47
  - !ruby/object:Gem::Version
47
48
  version: '0'
48
49
  requirements: []
49
- rubyforge_project:
50
- rubygems_version: 2.4.5
51
- signing_key:
50
+ rubygems_version: 3.0.8
51
+ signing_key:
52
52
  specification_version: 4
53
53
  summary: Has Many Through Hierarchy
54
54
  test_files: []