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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c8a0abb5e281f32bf502b1de5c76ce89d8f39414a5e03b5f499339a6d253fee
4
- data.tar.gz: 1c2a9895ad6841fcef7511c6dc3d591ead6ad944ffdd32b15327541204ab3a7b
3
+ metadata.gz: 5695d0df8966228572d9447611c31055e39fb9d18c3f2a8b98cf951efe5db86a
4
+ data.tar.gz: 985bcb344c25e6a78caa7c507bea05b54c8404e674fd1e11c749090482f6cfae
5
5
  SHA512:
6
- metadata.gz: 5dafc7f167fbdaa7de09c830a1fc37384e3c775bc12daa0e95a3bcd01b753869c558c95148b5dfe76e56ef94ded5df5a9ad554ee8e8250d90be9c2cc6e3875c2
7
- data.tar.gz: 5b6cdb88cad2df78e0cfc63a31389b6dd4fda8e06d82acd7ad9ddd0dd844038f5d0c1918b536972528b858260e7fa61645f0935e54ba84044b48a12f37b1e70b
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
@@ -1,3 +1,3 @@
1
1
  module Refer
2
- VERSION = "0.3.0"
2
+ VERSION = "0.5.0"
3
3
  end
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.3.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-15 00:00:00.000000000 Z
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.13
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