Class: Params::Encoder
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
-
#encoded ⇒ Object
encode after encryption to ensure Base64 compatibility in link.
-
#initialize(*args) ⇒ Encoder
constructor
A new instance of Encoder.
Methods included from Base
#clean_params, #crypter?, #crypter_off!, #crypter_on!, #use_crypter?
Constructor Details
#initialize(*args) ⇒ Encoder
Returns a new instance of Encoder.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/params/encoder.rb', line 7 def initialize *args raise "Encoder needs params to encode" if !args || args.empty? args = args.flatten = args.last if .kind_of? Hash @crypter = .delete(:crypter) end arg = args.first @params = case arg when Hash create_from arg when String arg else raise "Must be a Hash or String, was #{arg}" end end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
5 6 7 |
# File 'lib/params/encoder.rb', line 5 def params @params end |
Instance Method Details
#encoded ⇒ Object
encode after encryption to ensure Base64 compatibility in link
26 27 28 |
# File 'lib/params/encoder.rb', line 26 def encoded @encoded ||= use_crypter? ? Base64.encode64(encrypted_params) : Base64.encode64(params) end |