必要なノードが属性またはメソッドの場合、extends を呼び出すのは簡単です。
しかし、それが属性ではない場合はどうなりますか? インスタンス変数または attr アクセサーの可能性があります。
以下の例:
// dispatches is an attribute of the class
child :dispatches => :dispatches do
extends "/dispatches/_base"
end
# completed post is not an attribute of the class
if @completed_post
node(:post) do |post|
{
id: @completed_post.id.to_s,
_id: @completed_post.id.to_s,
display_text: @completed_post.display_text,
# and many others
}
end
この必要な追加ノードは、@instance または @object[:some_attribute] のいずれかです。