Class: Xendit::JSONSerializer
- Inherits:
-
Object
- Object
- Xendit::JSONSerializer
- Defined in:
- lib/xendit/json_serializer.rb
Class Method Summary collapse
-
.decode(params) ⇒ Object
If you using Rails then it will call ActiveSupport::JSON.decode Otherwise JSON.parse.
-
.encode(params) ⇒ Object
If you using Rails then it will call ActiveSupport::JSON.encode Otherwise JSON.pretty_generate.
Class Method Details
.decode(params) ⇒ Object
If you using Rails then it will call ActiveSupport::JSON.decode Otherwise JSON.parse
17 18 19 20 21 22 23 24 |
# File 'lib/xendit/json_serializer.rb', line 17 def decode(params) if defined?(ActiveSupport) && defined?(ActiveSupport::JSON) ActiveSupport::JSON.decode(params) else require 'json' unless defined?(JSON) JSON.parse(params) end end |
.encode(params) ⇒ Object
If you using Rails then it will call ActiveSupport::JSON.encode Otherwise JSON.pretty_generate
6 7 8 9 10 11 12 13 |
# File 'lib/xendit/json_serializer.rb', line 6 def encode(params) if defined?(ActiveSupport) && defined?(ActiveSupport::JSON) ActiveSupport::JSON.encode(params) else require 'json' unless defined?(JSON) JSON.pretty_generate(params) end end |