effective_learndash 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf3a76614af4d9fba4a5d9e483ecfc78ec821c042643b0d59508b42f80aead20
4
- data.tar.gz: 3e383233f17438db0bc4c134e8fb767183b3697b0036100ddf89e80961b42332
3
+ metadata.gz: 47f234d26d444d3ba71d72409db15186e4b1db00e1bf3c6aa007853143307265
4
+ data.tar.gz: d97eea26d3a6cce1d8df2f154b06b8dbc558e8df8c731fdbff268185cb3d465c
5
5
  SHA512:
6
- metadata.gz: 73041dc5fa8d6e130f865cd0ed5acf4c966ff1d7148168d6482f582f68c29d86fd8521c6d23aeb35227ca1f70810bd54b88408527767c3654b0998f8f6513d37
7
- data.tar.gz: 58d39dc3138ff44d2be3152aba69734f7f83146714b1b79a44b084cdc05dcd865974e457b4f61c2c3dd2436e5a81b709db7ea3cde5b68b807a325bf28df7c58e
6
+ metadata.gz: 6aeaa81878fe93276c6bcdc366ec2f61f1fdc5ee952a6b9328890387619605ddb7883210765f203bef8ae053065c781eb59c109b084b06d164be079ebe7689b8
7
+ data.tar.gz: 2d53168beee83ee8766389eaec11b48f6208e97e202d63ba3155f85278357b673ff1fab06de53cf9e8570fb57397ed5cf4cbfb4a2500a870c42691512fe061b8
@@ -30,7 +30,7 @@ module Effective
30
30
  def find_user(value)
31
31
  # Find by email
32
32
  if value.kind_of?(String) && value.include?('@')
33
- return find_by("/wp/v2/users", :email, value)
33
+ return find_by("/wp/v2/users", :email, email_for(value))
34
34
  end
35
35
 
36
36
  # Fetch by saved param value
@@ -39,7 +39,7 @@ module Effective
39
39
  return user if user.present?
40
40
 
41
41
  # Find by email
42
- email = value.try(:email)
42
+ email = email_for(value)
43
43
  user = find_by("/wp/v2/users", :email, email) if email
44
44
  return user if user.present?
45
45
 
@@ -122,7 +122,6 @@ module Effective
122
122
 
123
123
  # private under this point
124
124
 
125
-
126
125
  def user_id(resource)
127
126
  if resource.class.respond_to?(:effective_learndash_owner?) # This is a user
128
127
  resource.learndash_user&.user_id
@@ -147,18 +146,9 @@ module Effective
147
146
 
148
147
  def username_for(resource)
149
148
  raise('expected a LearnDash owner') unless resource.class.respond_to?(:effective_learndash_owner?) # This is a user
150
-
151
149
  name = EffectiveLearndash.wp_username_for(resource)
152
- name = "test#{name}" unless Rails.env.production?
153
- name
154
- end
155
-
156
- def email_for(resource)
157
- raise('expected a LearnDash owner') unless resource.class.respond_to?(:effective_learndash_owner?) # This is a user
158
150
 
159
- email = resource.email
160
- email = "test#{email}" unless Rails.env.production?
161
- email
151
+ Rails.env.production? ? name : "test#{name}"
162
152
  end
163
153
 
164
154
  def password_for(resource)
@@ -166,6 +156,13 @@ module Effective
166
156
  EffectiveLearndash.wp_password_for(resource)
167
157
  end
168
158
 
159
+ def email_for(value)
160
+ email = value.try(:email) || value.to_s
161
+ return nil unless email.present? && email.include?('@')
162
+
163
+ Rails.env.production? ? email : "test#{email}"
164
+ end
165
+
169
166
  def find(endpoint, params = nil)
170
167
  response = get(endpoint, params)
171
168
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveLearndash
2
- VERSION = '0.1.6'.freeze
2
+ VERSION = '0.1.7'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_learndash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect