On Mon, Oct 13, 2008 at 2:44 AM, Mislav Marohnić
<[EMAIL PROTECTED]> wrote:
> On Mon, Oct 13, 2008 at 02:35, Tarmo Tänav <[EMAIL PROTECTED]> wrote:
>>
>> Any ideas on how to make that work?
>
> The method could overwrite itself on first call.
> module Test
>   def self.env
>     e = 'production'
>     def self.env() 'development' end
>     e
>   end
> end
> Test.env # => 'production'
> Test.env # => 'development'

Sounds OK to me, generally we try to avoid requiring from inside
method definitions as they've historically been a cause of performance
issues. a simple memoized method would probably do the job too

@_env ||= begin
  require
  ...
end


-- 
Cheers

Koz

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" 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-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to