Categories
open all | close allTags
Aptana | フォーム | OpenID | 抽象化 | カテゴリ | 認証 | RESTful | テスト | デュアル・コア | プラグイン | アクセス制御 | スキンエンジン | rake | パソコン | 名称 | モデル | Migration | タグ | nextlink | CSRFSearch
わけが分からない
昨日の続きでまだうまくいきません。というかRuby(Rails?)の動きが理解できません。結局,プラグインの子クラスの一覧を取る機能は次のように実現しました。
def self.list
@@pluginlist ||= Array.new
if @@pluginlist.size == 0
@@pluginlist = Class.constants.select do |c|
cclass = c.constantize
if (cclass.is_a? Module) && (cclass.constants.include? 'Base')
FoodynPlugin::Base > (c+'::Base').constantize
end
end
end
@@pluginlist
end最初にpluginlistにArrayを入れてサイズを調べるといったまだるっこしいところをしているのは,またもやリロードのときにpluginlistが空になってしまうという問題に対応するためです。
中身はClassでの定数の配列を獲得し,それがModuleの名前かどうかを調べ,次にさらにそのモジュールでBaseという定数が定義されているかどうかを調べて,最後にFoodynPlugin::Baseと比較しています。
ところが,リロードすると最後の比較のときにtrueにならなきゃいけないところがなぜかnilに。理解できない。こまったなあ。
Comments
No comments yet. You can be the first!