Ruby\Rails は初めてで、恥を知れ :(
私は個人用のエンジンを開発しています (シンプルな管理パネル)。私が欲しいのは、次のようにメインアプリのモデルを構成できるようにすることです:
class User < ActiveRecord::Base
include Entropy::Configurable
entropy_config do
form_caption 'Editing user'
end
end
そして、エンジンのテンプレートでこれを行います:
<h1><%= @object.entropy_config :form_caption %></h1>
エンジンのモジュール:
module Entropy
module Configurable
def self.included(base)
## to call entropy_config in model class
base.send :extend, ClassMethods
end
def entropy_config(arg)
## ... I'm missing this part
end
module ClassMethods
@@config = { ... }
def entropy_config (&block)
class_eval &block
end
def form_caption(arg)
// skipping class identification
@@config[:user][:form_caption] = arg
end
end
end
end
問題は、@object で entropy_config を呼び出すと、Configurable モジュールから @@config にアクセスできないことです。私が間違っていることは何ですか?