aboutsummaryrefslogtreecommitdiffstats
path: root/core/plugin.rb
diff options
context:
space:
mode:
authorToshiaki Asai <qtoship@gmail.com>2013-02-15 02:04:11 +0900
committerToshiaki Asai <qtoship@gmail.com>2013-02-15 02:04:11 +0900
commit19feff7daeeacfd9f6565ce643e29b34701aefcd (patch)
tree837e3c266a8d01202d55a8b716dd6f195c127901 /core/plugin.rb
parent173b96d56bb9ce177dddeb677068346f48ac9119 (diff)
downloadmikutter-19feff7daeeacfd9f6565ce643e29b34701aefcd.tar.gz
DSLメソッドを拡張する仕組みを追加した
Diffstat (limited to 'core/plugin.rb')
-rw-r--r--core/plugin.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/core/plugin.rb b/core/plugin.rb
index f5f05c5f..c9b410ed 100644
--- a/core/plugin.rb
+++ b/core/plugin.rb
@@ -184,6 +184,19 @@ class Plugin
def defevent(event_name, options={})
Event[event_name].options.merge!({plugin: self}.merge(options)) end
+ # DSLメソッドを新しく追加する。
+ # 追加されたメソッドは呼ぶと &callback が呼ばれ、その戻り値が返される。引数も順番通り全て &callbackに渡される
+ # ==== Args
+ # [dsl_name] 新しく追加するメソッド名
+ # [&callback] 実行されるメソッド
+ # ==== Return
+ # self
+ def defdsl(dsl_name, &callback)
+ self.class.instance_eval {
+ define_method(dsl_name, &callback) }
+ self
+ end
+
# プラグインが Plugin.uninstall される時に呼ばれるブロックを登録する。
def onunload
@unload_hook ||= []