Sha256: 3fb743e286cdfd075573f884a81383e64063d08b8d818c1c09c5f6997df9af9f

Contents?: true

Size: 667 Bytes

Versions: 13

Compression:

Stored size: 667 Bytes

Contents

module ModernTimes
  module MarshalStrategy
    module JSON
      extend self

      def marshal_type
        :text
      end

      begin
        require 'json'
        def marshal(object)
          object.to_json
        end

        def unmarshal(msg)
          ::JSON::Parser.new(msg).parse
        end

        MarshalStrategy.register(:json => self)

      rescue LoadError => e
        def marshal(object)
          raise 'Error: JSON marshaling specified but json gem has not been installed'
        end

        def unmarshal(msg)
          raise 'Error: JSON marshaling specified but json gem has not been installed'
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
modern_times-0.3.12 lib/modern_times/marshal_strategy/json.rb
modern_times-0.3.11 lib/modern_times/marshal_strategy/json.rb
modern_times-0.3.10 lib/modern_times/marshal_strategy/json.rb
modern_times-0.3.9 lib/modern_times/marshal_strategy/json.rb
modern_times-0.3.8 lib/modern_times/marshal_strategy/json.rb
modern_times-0.3.7 lib/modern_times/marshal_strategy/json.rb
modern_times-0.3.6 lib/modern_times/marshal_strategy/json.rb
modern_times-0.3.5 lib/modern_times/marshal_strategy/json.rb
modern_times-0.3.4 lib/modern_times/marshal_strategy/json.rb
modern_times-0.3.3 lib/modern_times/marshal_strategy/json.rb
modern_times-0.3.2 lib/modern_times/marshal_strategy/json.rb
modern_times-0.3.1 lib/modern_times/marshal_strategy/json.rb
modern_times-0.3.0 lib/modern_times/marshal_strategy/json.rb