effective_orders 6.16.4 → 6.17.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: dc70e63297bba4d6b81db96f3fde44ea6cd46afb084498cb7e462c2bebe7c8ba
4
- data.tar.gz: bbd17f89c21994543925a0ddd5862ad3bc2e47318da9de27c45c41129e924e95
3
+ metadata.gz: bcd28b8d2dda1a9982419e2cfbb46de103d59de912ba3c95de4bd213389708cc
4
+ data.tar.gz: 216dab4a26eeeef06bf80b6a71e462ea0834bb084037bd9116b1057e68e8933c
5
5
  SHA512:
6
- metadata.gz: '087d6eb535b19ef97af82fe9cfd6b399da6954121e36567b316cbd8576d98b6de3d71dc9d10198bd08670f6ff2ad928591730bfa2fb4ee3175a6986c39dc2fcd'
7
- data.tar.gz: 1558fa105fbad61f78be06a0e0757dd823731e205915fb3d780a02eb51ab21feb38354b03c2598e08509e7de35daa22314b9152bde59b0a83d24cbb2f961dfed
6
+ metadata.gz: e8408c08ee2d9efaa894f53b3f01431410a8888af0cd0f37cca76b7bf429ad8fbe925eb239dd5d3db0a9b4f90459d7360a26fdd0e3d0d1a4a7d6da81c43d0011
7
+ data.tar.gz: 143ab80fe0744376ba4f3b2bbe1b66a4bbb5971de311cca4953458f983cd0f98fc263255a1d2bea249e0eb14c0301ec62ce2c5df6e0c1a33ab591090a5d5c01f
@@ -49,14 +49,47 @@ module ActsAsPurchasable
49
49
  validates_with Effective::SoldOutValidator, on: :create
50
50
  end
51
51
 
52
- scope :purchased, -> { where.not(purchased_order_id: nil) }
53
- scope :not_purchased, -> { where(purchased_order_id: nil) }
54
-
55
- scope :purchased_by, lambda { |user| joins(order_items: :order).where(orders: { purchased_by: user, status: :purchased }).distinct }
56
- scope :not_purchased_by, lambda { |user| where.not(id: purchased_by(user)) }
57
-
58
- scope :purchased_or_deferred, -> { joins(order_items: :order).where(orders: { status: [:purchased, :deferred] }) }
59
- scope :deferred, -> { joins(order_items: :order).where(orders: { status: :deferred }) }
52
+ scope :purchased, -> {
53
+ if respond_to?(:unarchived)
54
+ unarchived.where.not(purchased_order_id: nil)
55
+ else
56
+ where.not(purchased_order_id: nil)
57
+ end
58
+ }
59
+
60
+ scope :not_purchased, -> {
61
+ if respond_to?(:unarchived)
62
+ unarchived.where(purchased_order_id: nil)
63
+ else
64
+ where(purchased_order_id: nil)
65
+ end
66
+ }
67
+
68
+ scope :purchased_or_deferred, -> {
69
+ if respond_to?(:unarchived)
70
+ unarchived.joins(order_items: :order).where(orders: { status: [:purchased, :deferred] })
71
+ else
72
+ joins(order_items: :order).where(orders: { status: [:purchased, :deferred] })
73
+ end
74
+ }
75
+
76
+ scope :deferred, -> {
77
+ if respond_to?(:unarchived)
78
+ unarchived.joins(order_items: :order).where(orders: { status: :deferred })
79
+ else
80
+ joins(order_items: :order).where(orders: { status: :deferred })
81
+ end
82
+ }
83
+
84
+ scope :purchased_by, -> (user) {
85
+ if respond_to?(:unarchived)
86
+ unarchived.joins(order_items: :order).where(orders: { purchased_by: user, status: :purchased }).distinct
87
+ else
88
+ joins(order_items: :order).where(orders: { purchased_by: user, status: :purchased }).distinct
89
+ end
90
+ }
91
+
92
+ scope :not_purchased_by, -> (user) { where.not(id: purchased_by(user)) }
60
93
  end
61
94
 
62
95
  module ClassMethods
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '6.16.4'.freeze
2
+ VERSION = '6.17.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_orders
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.16.4
4
+ version: 6.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-11 00:00:00.000000000 Z
11
+ date: 2024-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails