Sha256: 89669087561da73fd1c1d6e9c2373ce818062bc21c6c3ec4a50f65edf2b4e454

Contents?: true

Size: 684 Bytes

Versions: 1

Compression:

Stored size: 684 Bytes

Contents

module Sufia
  module Export
    # a base class to convert an ActiveFedora object that contains permissions and allow for pretty json.
    #
    class Converter
      # overrides to_json to optionally allow for a pretty version of the json to be outputted
      #
      # @param [Boolean] pretty pass true to output formatted json using pretty_generate
      def to_json(options = {})
        pretty = options.delete(:pretty)
        json = super
        return json unless pretty
        JSON.pretty_generate(JSON.parse(json))
      end

      private

        def permissions(object)
          object.permissions.map { |p| PermissionConverter.new(p) }
        end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sufia-6.7.0 lib/sufia/export/converter.rb