Sha256: db2035a4e6d3f287ec4926e8d01ac5c9c781136bedbced4057f86fe07fe46d81

Contents?: true

Size: 969 Bytes

Versions: 6

Compression:

Stored size: 969 Bytes

Contents

module OodAppkit
  module Urls
    # A class used to handle URLs for the system file Editor app.
    class Editor < Url
      # @param (see Url#initialize)
      # @param edit_url [#to_s] the URL used to request the file editor api
      def initialize(edit_url: '/edit', template: '{/url*}{+path}', **kwargs)
        super(template: template, **kwargs)
        @edit_url = parse_url_segments(edit_url.to_s)
      end

      # URL to access this app's file editor API for a given absolute file path
      # @param opts [#to_h] the available options for this method
      # @option opts [#to_s, nil] :path ("") The absolute path to the file on
      #   the filesystem
      # @return [Addressable::URI] absolute url to access path in file editor
      #   api
      def edit(opts = {})
        opts = opts.to_h.compact.symbolize_keys

        path = opts.fetch(:path, "").to_s
        @template.expand url: @base_url + @edit_url, path: path
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ood_appkit-2.1.0 lib/ood_appkit/urls/editor.rb
ood_appkit-2.0.2 lib/ood_appkit/urls/editor.rb
ood_appkit-1.1.5 lib/ood_appkit/urls/editor.rb
ood_appkit-1.0.3 lib/ood_appkit/urls/editor.rb
ood_appkit-1.0.2 lib/ood_appkit/urls/editor.rb
ood_appkit-1.0.1 lib/ood_appkit/urls/editor.rb