Sha256: fdf17b4c9af8009104b39cc177038f156ad2cec135948357ff8416dbd94f8916

Contents?: true

Size: 575 Bytes

Versions: 7

Compression:

Stored size: 575 Bytes

Contents

# frozen_string_literal: true

module AdequateSerialization
  module Decorator
    class Null
      def decorate(result)
        result
      end
    end

    class Attachments
      attr_reader :attachments

      def initialize(attachments)
        @attachments = attachments
      end

      def decorate(result)
        attachments.each do |name, attachment|
          result[name] = attachment[result[:id]]
        end

        result
      end
    end

    def self.from(attachments)
      attachments.empty? ? Null.new : Attachments.new(attachments)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
adequate_serialization-2.0.1 lib/adequate_serialization/decorator.rb
adequate_serialization-2.0.0 lib/adequate_serialization/decorator.rb
adequate_serialization-1.0.1 lib/adequate_serialization/decorator.rb
adequate_serialization-1.0.0 lib/adequate_serialization/decorator.rb
adequate_serialization-0.1.1 lib/adequate_serialization/decorator.rb
adequate_serialization-0.1.0 lib/adequate_serialization/decorator.rb
adequate_serialization-0.0.1 lib/adequate_serialization/decorator.rb