services 6.0.5 → 7.0.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
  SHA256:
3
- metadata.gz: c3085ae1c41a776a15e333d0afbf240b7509f5921f4e75ceada90e834a8c6e05
4
- data.tar.gz: 1976cad3543d7f1bb9f5b40507dddde8fa3f805ae189b74a68e843cb68b6b036
3
+ metadata.gz: dff8b6c800a3b2ddd63f70e6f532f67bc96b6ad84433f82dddc38af9e3d5c8ca
4
+ data.tar.gz: d55ac6170d97a46766ca49184469496f8e50e3c79f651cb35becf33ca312dfc7
5
5
  SHA512:
6
- metadata.gz: b633bc24e6c9ede452b76301a1f2fb8478160320fe8e982c0527ee078c8d879375e3f610b3247754853aa0c4faa9a043de865ab70b1b6cccc9eadf446fb1f5ab
7
- data.tar.gz: 2bf7df9ef18291cf448a8a6af7e5e850af1027ba1cbcb223127e021e0b31e5191b988db6a882f3a9a51482adae4818b957c8352e52b07c0361ba0ff1d1940234
6
+ metadata.gz: 30794a6468fb2d966a73690336230fb49f5ce33ef42cc70c18a04e30dddd8efc71c85d9eb07a0f52775c04baa6f2c5216bc290b7fa03d0373748e5549560aad6
7
+ data.tar.gz: d61ca8f78c4d902bbb5b0ee7f697a3236e4526f6fc9b249fb24c1abf7bb052e429c59cf7f981f5c66509bcfba8d9501555226cb1652438b898513ae0fbd1db6b
@@ -29,8 +29,9 @@ module Services
29
29
 
30
30
  object_table_id = "#{object_class.table_name}.id"
31
31
 
32
- special_conditions = conditions.extract!(:id_not, :order, :limit, :page, :per_page)
33
- special_conditions[:order] = object_table_id unless special_conditions.has_key?(:order)
32
+ unless conditions.key?(:order)
33
+ conditions[:order] = object_table_id
34
+ end
34
35
 
35
36
  scope = conditions.delete(:scope).try(:dup) || object_class.public_send(ActiveRecord::VERSION::MAJOR == 3 ? :scoped : :all)
36
37
  scope = scope.where(object_table_id => ids) unless ids.empty?
@@ -50,18 +51,26 @@ module Services
50
51
  end
51
52
  end
52
53
 
53
- scope = process(scope, conditions)
54
+ conditions.each do |k, v|
55
+ if new_scope = process(scope, k, v)
56
+ conditions.delete k
57
+ scope = new_scope
58
+ end
59
+ end
54
60
 
55
- # If a JOIN is involved, use a subquery to make sure we're getting DISTINCT records.
61
+ # If a JOIN is involved, use a subquery to make sure we get DISTINCT records.
56
62
  if scope.to_sql =~ / join /i
57
63
  scope = object_class.where(id: scope.select("DISTINCT #{object_table_id}"))
58
64
  end
59
65
  end
60
66
 
61
- special_conditions.each do |k, v|
67
+ conditions.each do |k, v|
62
68
  case k
63
69
  when :id_not
64
70
  scope = scope.where.not(id: v)
71
+ when /\Acreated_(before|after)\z/
72
+ operator = $1 == 'before' ? '<' : '>'
73
+ scope = scope.where("created_at #{operator} ?", v)
65
74
  when :order
66
75
  next unless v
67
76
  case v
@@ -93,7 +102,7 @@ module Services
93
102
  when :per_page
94
103
  scope = scope.per(v)
95
104
  else
96
- raise ArgumentError, "Unexpected special condition: #{k}"
105
+ raise ArgumentError, "Unexpected condition: #{k}"
97
106
  end
98
107
  end
99
108
 
@@ -1,3 +1,3 @@
1
1
  module Services
2
- VERSION = '6.0.5'.freeze
2
+ VERSION = '7.0.0'.freeze
3
3
  end
@@ -45,7 +45,7 @@ describe Services::Logger::Redis do
45
45
  %i(message severity).each do |k|
46
46
  log[k] = log[k].try(:to_s) || ''
47
47
  end
48
- log[:meta] = if log.has_key?(:meta)
48
+ log[:meta] = if log.key?(:meta)
49
49
  log[:meta].stringify_keys
50
50
  else
51
51
  {}
@@ -59,7 +59,7 @@ describe Services::Logger::Redis do
59
59
  Timecop.freeze log[:time] do
60
60
  args = [log[:message]]
61
61
  args.push log[:meta] || {}
62
- args.push log[:severity] if log.has_key?(:severity)
62
+ args.push log[:severity] if log.key?(:severity)
63
63
  logger.log *args
64
64
  end
65
65
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: services
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.5
4
+ version: 7.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manuel Meurer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-10 00:00:00.000000000 Z
11
+ date: 2018-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake