Module: EffectiveLearndash
- Includes:
- EffectiveGem
- Defined in:
- lib/effective_learndash.rb,
lib/effective_learndash/engine.rb,
lib/effective_learndash/version.rb,
lib/generators/effective_learndash/install_generator.rb
Defined Under Namespace
Modules: Generators
Classes: Engine
Constant Summary
collapse
- WP_USERNAME_PROC =
Proc.new { |user| "user#{user.id}" }
- WP_PASSWORD_PROC =
Proc.new { |user| SecureRandom.base64(12) }
- VERSION =
'0.1.2'.freeze
Class Method Summary
collapse
Class Method Details
.api ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/effective_learndash.rb', line 20
def self.api
raise('please set learndash_url in config/initializers/effective_learndash.rb') unless learndash_url.present?
raise('please set learndash_username in config/initializers/effective_learndash.rb') unless learndash_username.present?
raise('please set learndash_password in config/initializers/effective_learndash.rb') unless learndash_password.present?
Effective::LearndashApi.new(
url: learndash_url,
username: learndash_username,
password: learndash_password
)
end
|
.config_keys ⇒ Object
10
11
12
13
14
15
16
|
# File 'lib/effective_learndash.rb', line 10
def self.config_keys
[
:learndash_url, :learndash_username, :learndash_password,
:wp_username, :wp_password,
:layout
]
end
|
.wp_password ⇒ Object
36
37
38
|
# File 'lib/effective_learndash.rb', line 36
def self.wp_password
config[:wp_password] || WP_PASSWORD_PROC
end
|
.wp_password_for(owner) ⇒ Object
47
48
49
50
|
# File 'lib/effective_learndash.rb', line 47
def self.wp_password_for(owner)
raise('expecting a learndash owner') unless owner.class.respond_to?(:effective_learndash_owner?)
owner.instance_exec(owner, &wp_password)
end
|
.wp_username ⇒ Object
32
33
34
|
# File 'lib/effective_learndash.rb', line 32
def self.wp_username
config[:wp_username] || WP_USERNAME_PROC
end
|
.wp_username_for(owner) ⇒ Object
The user.learndash_username is the source of truth
This is the backup to generate a new username
42
43
44
45
|
# File 'lib/effective_learndash.rb', line 42
def self.wp_username_for(owner)
raise('expecting a learndash owner') unless owner.class.respond_to?(:effective_learndash_owner?)
owner.instance_exec(owner, &wp_username)
end
|