Class: Travis::Yaml::SecureString
- Inherits:
-
Object
- Object
- Travis::Yaml::SecureString
- Defined in:
- lib/travis/yaml/secure_string.rb
Instance Attribute Summary collapse
-
#decrypted_string ⇒ Object
Returns the value of attribute decrypted_string.
-
#encrypted_string ⇒ Object
Returns the value of attribute encrypted_string.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #decrypt ⇒ Object
- #decrypted? ⇒ Boolean
- #encrypt ⇒ Object
- #encrypted? ⇒ Boolean
- #hash ⇒ Object
-
#initialize(string, encrypted = true) ⇒ SecureString
constructor
A new instance of SecureString.
- #inspect ⇒ Object
Constructor Details
#initialize(string, encrypted = true) ⇒ SecureString
Returns a new instance of SecureString.
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/travis/yaml/secure_string.rb', line 4 def initialize(string, encrypted = true) unless string.respond_to? :to_str raise ArgumentError, "secure string needs to be a string, not a %p" % string.class.name.downcase end if encrypted @encrypted_string = string.to_str else @decrypted_string = string.to_str end end |
Instance Attribute Details
#decrypted_string ⇒ Object
Returns the value of attribute decrypted_string.
3 4 5 |
# File 'lib/travis/yaml/secure_string.rb', line 3 def decrypted_string @decrypted_string end |
#encrypted_string ⇒ Object
Returns the value of attribute encrypted_string.
3 4 5 |
# File 'lib/travis/yaml/secure_string.rb', line 3 def encrypted_string @encrypted_string end |
Instance Method Details
#==(other) ⇒ Object
37 38 39 |
# File 'lib/travis/yaml/secure_string.rb', line 37 def ==(other) other.encrypted_string == encrypted_string and other.decrypted_string == decrypted_string if other.is_a? SecureString end |
#decrypt ⇒ Object
23 24 25 26 |
# File 'lib/travis/yaml/secure_string.rb', line 23 def decrypt return unless encrypted? @decrypted_string = yield(encrypted_string) end |
#decrypted? ⇒ Boolean
19 20 21 |
# File 'lib/travis/yaml/secure_string.rb', line 19 def decrypted? !!decrypted_string end |
#encrypt ⇒ Object
28 29 30 31 |
# File 'lib/travis/yaml/secure_string.rb', line 28 def encrypt return unless decrypted? @encrypted_string = yield(decrypted_string) end |
#encrypted? ⇒ Boolean
15 16 17 |
# File 'lib/travis/yaml/secure_string.rb', line 15 def encrypted? !!encrypted_string end |
#hash ⇒ Object
41 42 43 |
# File 'lib/travis/yaml/secure_string.rb', line 41 def hash encrypted_string.hash | decrypted_string.hash end |
#inspect ⇒ Object
33 34 35 |
# File 'lib/travis/yaml/secure_string.rb', line 33 def inspect "[SECURE]".freeze end |