Sha256: 4986d1d486562169b210717114684c32a9bdc0731504957d2c0d8666f7c8157b

Contents?: true

Size: 445 Bytes

Versions: 2

Compression:

Stored size: 445 Bytes

Contents

require 'base64'
require 'multi_json'
require 'active_support/core_ext/module/delegation'

module FrontKit
  class Serializer
    def encode(hash)
      Base64.encode64(MultiJson.encode(hash)).gsub(/\s+/, '')
    end
    
    def decode(str)
      MultiJson.decode(Base64.decode64(str))
    end
  end
  
  class << self
    attr_accessor :serializer
    delegate :encode, :decode, to: 'serializer'
  end
  
  self.serializer = Serializer.new
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
frontkit-rails-0.0.5 lib/frontkit-rails/serializer.rb
frontkit-rails-0.0.4 lib/frontkit-rails/serializer.rb