Class: Refcode::Encoder
- Inherits:
-
Object
- Object
- Refcode::Encoder
- Defined in:
- lib/refcode/encoder.rb
Instance Attribute Summary collapse
-
#salt ⇒ Object
Returns the value of attribute salt.
-
#secret ⇒ Object
Returns the value of attribute secret.
Instance Method Summary collapse
- #decode(val) ⇒ Object
- #encode(val) ⇒ Object
-
#initialize {|_self| ... } ⇒ Encoder
constructor
A new instance of Encoder.
Constructor Details
#initialize {|_self| ... } ⇒ Encoder
Returns a new instance of Encoder.
7 8 9 |
# File 'lib/refcode/encoder.rb', line 7 def initialize yield self if block_given? end |
Instance Attribute Details
#salt ⇒ Object
Returns the value of attribute salt.
5 6 7 |
# File 'lib/refcode/encoder.rb', line 5 def salt @salt end |
#secret ⇒ Object
Returns the value of attribute secret.
5 6 7 |
# File 'lib/refcode/encoder.rb', line 5 def secret @secret end |
Instance Method Details
#decode(val) ⇒ Object
13 14 15 |
# File 'lib/refcode/encoder.rb', line 13 def decode val YAML.load(decrypt(Base64URL.decode(val))) end |
#encode(val) ⇒ Object
10 11 12 |
# File 'lib/refcode/encoder.rb', line 10 def encode val Base64URL.encode(encrypt(YAML.dump(val))) end |