Inheriting behaviors

Hi all,

I was wondering is it possible to inherit behaviors? Example: The
mailer
behavior defines some form tags that could be made fairly generic with
minor
tweaking. It seems like generic form tags would be pretty useful. I
was
trying to do something like:

module FormBehavior
def self.append_features(base)
base.class_eval %{
define_tags do
tag “#{form_name}:form” do |tag|
tag_attr = tag.attr.symbolize_keys
results = %Q()
results << tag.expand
results << %Q()
end
end
}
end
end

But #{form_name} and #{page.url} both get evaluated in the context of
the
module. There is most likely a simpel way around this but at least that
code shows the gist of what I’m trying to do.

Any ideas, help, thoughts would be appriciated.

Thanks!
Justin

Justin Marney wrote:

base.class_eval %{
end
end

But #{form_name} and #{page.url} both get evaluated in the context of the
module. There is most likely a simpel way around this but at least that
code shows the gist of what I’m trying to do.

Any ideas, help, thoughts would be appriciated.

Why not do this:

require ‘behaviors/mailer_behavior’

MailerBehavior.define_tags do
define_tags do
tag “#{form_name}:form” do |tag|
tag_attr = tag.attr.symbolize_keys
results = %Q()
results << tag.expand
results << %Q()
end
end
end

?


John L.
http://wiseheartdesign.com

During a migration to radiant, we had to correct the publish date of
archived posts via the database; we had a little idea:

‘status of a page’ select box is now:
-draft
-reviewed
-published
-hidden

wouldn’t it be nice to have:
-draft
-reviewed
-publish now
-publish on…
-hidden

It allows the schedule of a post, and even modifying a publication
date in the past.