# Inheriting behaviors

**URL:** <https://www.ruby-forum.com/t/inheriting-behaviors/62970>\
**Category:** Radiant CMS\
**Created:** [June 9, 2006, 11:45pm UTC](https://www.ruby-forum.com/t/inheriting-behaviors/62970 "2006-06-09T23:45:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Justin\_Marney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9bd4f/32.png) [@Justin\_Marney](https://www.ruby-forum.com/u/Justin_Marney)\
**Post date:** [June 9, 2006, 11:45pm UTC](https://www.ruby-forum.com/t/inheriting-behaviors/62970/1 "2006-06-09T23:45:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Justin\_Marney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9bd4f/32.png) [@Justin\_Marney](https://www.ruby-forum.com/u/Justin_Marney)\
**Post date:** [June 12, 2006, 5:46pm UTC](https://www.ruby-forum.com/t/inheriting-behaviors/62970/2 "2006-06-12T17:46:08Z")

</div>

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](http://wiseheartdesign.com)

---

<div class="post-metadata">

**Author:** ![Justin\_Marney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9bd4f/32.png) [@Justin\_Marney](https://www.ruby-forum.com/u/Justin_Marney)\
**Post date:** [June 13, 2006, 10:36am UTC](https://www.ruby-forum.com/t/inheriting-behaviors/62970/3 "2006-06-13T10:36:17Z")

</div>

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.
