Sha256: 2b3e2c5b53f278b5b4c1b457f8f6f451235248917dd9806e5a5737e31ff95471

Contents?: true

Size: 1.24 KB

Versions: 7

Compression:

Stored size: 1.24 KB

Contents

module Neovim
  class Plugin
    # @api private
    class Handler
      attr_reader :block

      def self.unqualified(name, sync, options, block)
        new(
          nil,
          nil,
          name,
          sync,
          options.merge(:qualified => false),
          block
        )
      end

      def initialize(source, type, name, sync, options, block)
        @source = source
        @type = type.to_sym if type.respond_to?(:to_sym)
        @name = name.to_s
        @sync = !!sync
        @options = options
        @block = block || Proc.new {}
        @qualified =
          options.key?(:qualified) ? options.delete(:qualified) : true
      end

      def sync?
        @sync
      end

      def qualified?
        @qualified
      end

      def qualified_name
        return @name unless qualified?

        if @type == :autocmd
          pattern = @options.fetch(:pattern, "*")
          "#{@source}:#{@type}:#{@name}:#{pattern}"
        else
          "#{@source}:#{@type}:#{@name}"
        end
      end

      def to_spec
        {
          :type => @type,
          :name => @name,
          :sync => @sync,
          :opts => @options,
        }
      end

      def call(*args)
        @block.call(*args)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
neovim-0.2.5 lib/neovim/plugin/handler.rb
neovim-0.2.4 lib/neovim/plugin/handler.rb
neovim-0.2.3 lib/neovim/plugin/handler.rb
neovim-0.2.2 lib/neovim/plugin/handler.rb
neovim-0.2.1 lib/neovim/plugin/handler.rb
neovim-0.2.0 lib/neovim/plugin/handler.rb
neovim-0.1.0 lib/neovim/plugin/handler.rb