Monkey patches are evil.
On Jun 4, 2011 3:42 AM, "Michael Pavling" <[email protected]> wrote:
> On 3 June 2011 18:34, Kevin <[email protected]> wrote:
>> Out of curiosity what should one do if one wants to have a method
inherited
>> by all models?
>
> You can monkey patch Object or Class if you really want...
>
> # patch in environment.rb
> class Object
> def your_method
> puts "my method is here"
> end
> end
>
> # console
>>> o = AnyObject.new
> => #<AnyObject id: etc>
>>> o.your_method
> my method is here
> => nil
>>> String.your_method
> my method is here
> => nil
>
> --
> You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
[email protected].
> For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to