procore-sift 0.12.0 → 0.13.0

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: edabe4ead843ee8dd551b70d2408899b88dca98d
4
- data.tar.gz: bbc128cae2da284235591505bfb60a4f7fcc3e93
3
+ metadata.gz: f18552ca0480672282156cc7664312b98dbad772
4
+ data.tar.gz: 81612b0c72fa8827496fe23af9e804993d4d1484
5
5
  SHA512:
6
- metadata.gz: 5b699d7819a4ab9e29cedc03ccc26fa113e5603abff8c7e700421ecf2eca79bdd25b65c726898ef5e9018b57ca68e1ca4dfb10b7d13589dd71854e6b90d4391f
7
- data.tar.gz: c5bec1b452aa2bf55192602c0316d367d044c32224b8c77d0db41eb6e2508a4725c325d024711e0e39f66d52a83548ffcab74823d781126555f4bcf45ba098b9
6
+ metadata.gz: 0dc882e598295f080ead00b2b791ecbd5a86722ac7108ce37d00835b7c47790d4dc90d70140cc0bfd8d0b9f66b8b0861072b24e7c84f5ac69170365aedf82572
7
+ data.tar.gz: 753c9f44ea32b532bc1fb99d5d1b840255c3132eaf5bcfab5842eec2778439b2069e0c631d4a17aba4b41dec583b17f243e341c9f7557ea4aae1ae30ab785403
data/lib/procore-sift.rb CHANGED
@@ -39,20 +39,31 @@ module Sift
39
39
  def filter_validator
40
40
  @_filter_validator ||= FilterValidator.build(
41
41
  filters: filters,
42
- sort_fields: self.class.sort_fields,
42
+ sort_fields: sort_fields,
43
43
  filter_params: filter_params,
44
44
  sort_params: sort_params,
45
45
  )
46
46
  end
47
47
 
48
48
  def filters
49
- self.class.filters
49
+ self.class.ancestors
50
+ .take_while { |klass| klass.name != "Sift" }
51
+ .flat_map { |klass| klass.try(:filters) }
52
+ .compact
53
+ .uniq { |f| [f.param, f.class] }
50
54
  end
51
55
 
52
56
  def sorts_exist?
53
57
  filters.any? { |filter| filter.is_a?(Sort) }
54
58
  end
55
59
 
60
+ def sort_fields
61
+ self.class.ancestors
62
+ .take_while { |klass| klass.name != "Sift" }
63
+ .flat_map { |klass| klass.try(:sort_fields) }
64
+ .compact
65
+ end
66
+
56
67
  class_methods do
57
68
  def filter_on(parameter, type:, internal_name: parameter, default: nil, validate: nil, scope_params: [])
58
69
  filters << Filter.new(parameter, type, internal_name, default, validate, scope_params)
@@ -52,7 +52,7 @@ module Sift
52
52
 
53
53
  def to_type(filter)
54
54
  if filter.type == :boolean
55
- if Rails.version.starts_with?("5")
55
+ if Rails.version.starts_with?('5') || Rails.version.starts_with?('6')
56
56
  ActiveRecord::Type::Boolean.new.cast(filter_params[filter.param])
57
57
  else
58
58
  ActiveRecord::Type::Boolean.new.type_cast_from_user(filter_params[filter.param])
@@ -53,7 +53,7 @@ module Sift
53
53
  end
54
54
 
55
55
  def boolean_value
56
- if Rails.version.starts_with?("5")
56
+ if Rails.version.to_i >= 5
57
57
  ActiveRecord::Type::Boolean.new.cast(value)
58
58
  else
59
59
  ActiveRecord::Type::Boolean.new.type_cast_from_user(value)
data/lib/sift/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sift
2
- VERSION = "0.12.0".freeze
2
+ VERSION = "0.13.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: procore-sift
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Procore Technologies
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-20 00:00:00.000000000 Z
11
+ date: 2020-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -70,16 +70,16 @@ dependencies:
70
70
  name: rubocop
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: 0.71.0
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: 0.71.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: sqlite3
85
85
  requirement: !ruby/object:Gem::Requirement