跳至内容 跳至搜索
方法
C
R

类公共方法

current()

返回当前编辑器模式(如果已知)。首先检查 RAILS_EDITOR 环境变量,如果不存在,则检查 EDITOR 环境变量。

# File activesupport/lib/active_support/editor.rb, line 28
def current
  if @current == false
    @current = if editor_name = ENV["RAILS_EDITOR"] || ENV["EDITOR"]
      @editors[editor_name]
    end
  end
  @current
end

register(name, url_pattern, aliases: [])

注册用于在给定编辑器中打开文件的 URL 模式。这允许 Rails 生成可点击的链接来控制已知的编辑器。

示例

ActiveSupport::Editor.register(“myeditor”, “myeditor://%s:%d”)

# File activesupport/lib/active_support/editor.rb, line 17
def register(name, url_pattern, aliases: [])
  editor = new(url_pattern)
  @editors[name] = editor
  aliases.each do |a|
    @editors[a] = editor
  end
end