感觉这是个会经常出现的场景: 用 CoffeeScript 写了一个 Class 来控制 UI,一如:
class Step
    constructor: ({selector: @selector, container: @container}) ->
        @self = $(@selector)
        @content = $(@container)
        @size = $("#{@selector}>.step").length
        @active = $("#{@selector} .active.step")
        return
    nextStep: (html) ->
        @active.removeClass("active").addClass("completed").next().addClass("active") 
        @__mountContent html
        return
    __clearContent: ->
        @content.html()
    __mountContent: (data) ->
        @__clearContent()
        @content.html data
在 Rails 中用 remote 更新 UI 的时候写到了形如
var step = new Step({
    selector: 'registStep',
    container: '#registContent'
});
step.nextStep("<%= j render partial: 'stuff/dashboard/set_college_form', locals: {colleges: College.all}%>");
调用 class 中的 function 来更新,结果就是 class 被 CoffeeScript 默认的匿名包给屏蔽,并没有暴露给全局。
在不更改 CoffeeScript 默认渲染方式的情况下,如何可以优雅地把这种 component 暴露给全局呢?
目前有一种方式比如写完 class 之后写: window.Step = Step,但是一点都不优雅……新建的时候居然要  新建的时候写 var step = new window.Step(...)var step = new Step(...);倒是可以……
所以最终相对优雅的方法是 @rei 和 @greatghoul 提出的用this来包 class 名称的做法:
如:
class @Step
    ........