refer 1.0.0 → 1.0.2
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 +6 -0
- data/lib/refer/model.rb +4 -4
- data/lib/refer/version.rb +1 -1
- 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: a4e58649b749077a18161b08d1aa37957d51dbb7b9aa16e38adc1a20b9aa5877
|
4
|
+
data.tar.gz: 88504a15fb41af9cb252672786cbfa3d98be7f6fdb11a7d1529d4ab87227f899
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ba2c413666a47f0ade8d7225447bc8b9a1860a19d430cebabf14cda312644636831131e1e27f296c06b22348a62242e8f6c17fb4edbe666070387c484d7c4df
|
7
|
+
data.tar.gz: 695b3b72061510117c98e9b5781a02d27f8f58cc10f8818e3eebb23ad8e215d9a7a54ff20bc86bd034a9ea7ef6c73f6fb14923b3dda8ff756b3d6a94a16076a1
|
@@ -10,6 +10,12 @@ module Refer
|
|
10
10
|
self.referrer = referral_code&.referrer
|
11
11
|
end
|
12
12
|
|
13
|
+
validate :ensure_not_self_referral
|
14
|
+
|
15
|
+
def ensure_not_self_referral
|
16
|
+
errors.add(:base, "Self-referrals are not allowed") if referrer == referee
|
17
|
+
end
|
18
|
+
|
13
19
|
def complete!(**attributes)
|
14
20
|
return if completed_at?
|
15
21
|
|
data/lib/refer/model.rb
CHANGED
@@ -3,10 +3,10 @@ module Refer
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
included do
|
6
|
-
has_many :referral_codes,
|
7
|
-
has_many :referrals,
|
8
|
-
has_one :referral,
|
9
|
-
delegate :referrer, to: :referral
|
6
|
+
has_many :referral_codes, as: :referrer, class_name: "Refer::ReferralCode", dependent: :destroy
|
7
|
+
has_many :referrals, as: :referrer, class_name: "Refer::Referral", dependent: :destroy
|
8
|
+
has_one :referral, as: :referee, class_name: "Refer::Referral", dependent: :destroy
|
9
|
+
delegate :referrer, to: :referral, allow_nil: true
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
data/lib/refer/version.rb
CHANGED
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: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Oliver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-07 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.23
|
79
79
|
signing_key:
|
80
80
|
specification_version: 4
|
81
81
|
summary: Referral codes & affiliate links for Ruby on Rails apps
|