Sha256: 1c74f9154e0fb8ade25e37750ddd78b2781e4fb91db30e33d80ae81a11be29c4

Contents?: true

Size: 426 Bytes

Versions: 3

Compression:

Stored size: 426 Bytes

Contents

# include this in your representer, and you will always return all defined keys (even if their value is nil)
module ServiceTemplate
  module Representable
    module IncludeNil
      def self.included base
        base.extend ClassMethods
      end

      module ClassMethods
        def property(name, options={}, &block)
          super(name, options.merge(render_nil: true), &block)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
service_template-0.5.2 lib/service_template/output_formatters/include_nil.rb
service_template-0.5.1 lib/service_template/output_formatters/include_nil.rb
service_template-0.5.0 lib/service_template/output_formatters/include_nil.rb