Class: WordpressDeploy::Wordpress::Salts
- Inherits:
-
Object
- Object
- WordpressDeploy::Wordpress::Salts
- Defined in:
- lib/wordpress_deploy/wordpress/salts.rb
Constant Summary collapse
- @@keys =
[ :@auth_key, :@secure_auth_key, :@logged_in_key, :@nonce_key, :@auth_salt, :@secure_auth_salt, :@logged_in_salt, :@nonce_salt ]
Class Method Summary collapse
-
.salt ⇒ Object
Returns 64 psuedo-random characters as a string Characters can be a-zA-z or !@#$%^&*()-~+=|/{}:;,.?<>[].
Instance Method Summary collapse
-
#initialize(&block) ⇒ Salts
constructor
A new instance of Salts.
-
#method_missing(method, *args, &block) ⇒ Object
Respond with the named configuration if the method name is a a valid configuration that has been loaded.
-
#respond_to?(method) ⇒ Boolean
Respond to an configuration name as though it is a method.
Constructor Details
#initialize(&block) ⇒ Salts
Returns a new instance of Salts.
11 12 13 14 15 16 17 |
# File 'lib/wordpress_deploy/wordpress/salts.rb', line 11 def initialize(&block) ## # Create initial values for all the salts @@keys.each { |key| instance_variable_set(key, Salts.salt) } instance_eval(&block) if block_given? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
Respond with the named configuration if the method name is a a valid configuration that has been loaded.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/wordpress_deploy/wordpress/salts.rb', line 29 def method_missing(method, *args, &block) instance_variable = "@#{method.to_s}".to_sym if @@keys.include? instance_variable args.flatten! # Set the instance variable to the value passed in unless args.empty? instance_variable_set(instance_variable, args[0]) end # Return the value of the instance_variable instance_variable_get(instance_variable) else super end end |
Class Method Details
.salt ⇒ Object
Returns 64 psuedo-random characters as a string Characters can be a-zA-z or !@#$%^&*()-~+=|/{}:;,.?<>[]
22 23 24 |
# File 'lib/wordpress_deploy/wordpress/salts.rb', line 22 def self.salt salt_array.sample(64).join("") end |
Instance Method Details
#respond_to?(method) ⇒ Boolean
Respond to an configuration name as though it is a method.
48 49 50 51 52 |
# File 'lib/wordpress_deploy/wordpress/salts.rb', line 48 def respond_to?(method) instance_variable = "@#{method.to_s}".to_sym return true if @@keys.include? instance_variable super end |