作者热门文章
- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我想指出,这完全是一个虚构的问题。我知道还有其他方法可以做到这一点。
我想像这样声明一个模块
module Foo
# some logic here to
# get instance method 'foo' on
# a later defined class
end
然后我想声明一个类:
class Foo::Bar
end
然后不使用 include 或 extend 就可以做到这一点:
Foo::Bar.new.foo
并让它调用我在模块 Foo 中定义的 foo 方法
最佳答案
module Foo
class Bar
def foo
puts "erik is a dummy"
end
end
end
Foo::Bar.new.foo
=> erik is a dummy
关于ruby - 稍后定义的类的模块实例方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11253282/
我正在编写一个插件,有一个ajax调用向用户显示数据。 如果用户想在ajax成功时添加一些js?他可以从他的 js 脚本中做到这一点吗,比如定位这个 ajax 成功事件。 例如: $(documen
我有 html 代码,例如 - x 最初插入 div 'insert_calendar_eda_form'。 Javascript代码 calendar_eda_add
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 3 年前。 Improve this qu
我已经使用命令 sudo start myservice 启动了一个 upstart 服务。我想要一种方法,以便稍后我(或任何人)可以检查该服务是否已启动并正在运行。检查它的命令是什么? 最佳答案 找
我是一名优秀的程序员,十分优秀!