Sha256: 0b3af3b6c543bd3211eda2aabef201ec4f7261d6eb04042b5daa177134ece8b6

Contents?: true

Size: 415 Bytes

Versions: 5

Compression:

Stored size: 415 Bytes

Contents

# include this in your representer, and you will always return all defined keys (even if their value is nil)
module Napa
  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

5 entries across 5 versions & 1 rubygems

Version Path
napa-0.5.0 lib/napa/output_formatters/include_nil.rb
napa-0.4.3 lib/napa/output_formatters/include_nil.rb
napa-0.4.1 lib/napa/output_formatters/include_nil.rb
napa-0.4.0 lib/napa/output_formatters/include_nil.rb
napa-0.3.0 lib/napa/output_formatters/include_nil.rb