refer 0.3.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/refer/referral.rb +5 -0
- data/lib/refer/version.rb +1 -1
- data/lib/refer.rb +1 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5695d0df8966228572d9447611c31055e39fb9d18c3f2a8b98cf951efe5db86a
|
4
|
+
data.tar.gz: 985bcb344c25e6a78caa7c507bea05b54c8404e674fd1e11c749090482f6cfae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d04f1b17398ceaf1f6b405d29d5f3e6136caad0438f5bc3b735d167ff41586f4d869bcf04fbcf823b0030de221145cd44263bf72f2834a5aa02fa45c9dc0bb61
|
7
|
+
data.tar.gz: 74b1a140b5856cb05fef1ffcbaa51bd1730cc83eee0ca8497c84a2a4bb9d15bd39857549087ba54c198a4e115e72a5e50e20f8677909965a6b05ca0d87bc86e5
|
@@ -4,12 +4,17 @@ module Refer
|
|
4
4
|
belongs_to :referee, polymorphic: true
|
5
5
|
belongs_to :referral_code, optional: true, counter_cache: true
|
6
6
|
|
7
|
+
scope :completed, -> { where.not(completed_at: nil) }
|
8
|
+
|
7
9
|
before_validation do
|
8
10
|
self.referrer = referral_code&.referrer
|
9
11
|
end
|
10
12
|
|
11
13
|
def complete!(**attributes)
|
14
|
+
return if completed_at?
|
15
|
+
|
12
16
|
update attributes.with_defaults(completed_at: Time.current)
|
17
|
+
Refer.referral_completed&.call(self)
|
13
18
|
end
|
14
19
|
end
|
15
20
|
end
|
data/lib/refer/version.rb
CHANGED
data/lib/refer.rb
CHANGED
@@ -12,6 +12,7 @@ module Refer
|
|
12
12
|
config_accessor :overwrite_cookie, default: true
|
13
13
|
config_accessor :track_visits, default: true
|
14
14
|
config_accessor :mask_ips, default: true
|
15
|
+
config_accessor :referral_completed
|
15
16
|
|
16
17
|
class Error < StandardError; end
|
17
18
|
class AlreadyReferred < Error; end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: refer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Oliver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-07-
|
11
|
+
date: 2024-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '0'
|
77
77
|
requirements: []
|
78
|
-
rubygems_version: 3.5.
|
78
|
+
rubygems_version: 3.5.14
|
79
79
|
signing_key:
|
80
80
|
specification_version: 4
|
81
81
|
summary: Referral codes & affiliate links for Ruby on Rails apps
|