File: coder.rb

package info (click to toggle)
ruby-noticed 3.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 324 kB
  • sloc: ruby: 1,186; makefile: 4
file content (21 lines) | stat: -rw-r--r-- 554 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require "active_job/arguments"

module Noticed
  class Coder
    def self.load(data)
      return if data.nil?
      ActiveJob::Arguments.send(:deserialize_argument, data)
    rescue ActiveRecord::RecordNotFound => error
      {noticed_error: error.message, original_params: data}
    end

    def self.dump(data)
      return if data.nil?
      if ActiveJob::Arguments.respond_to?(:serialize_argument, true)
        ActiveJob::Arguments.send(:serialize_argument, data)
      else
        ActiveJob::Arguments.serialize(data)
      end
    end
  end
end