Afficher un message
Vieux 12/03/2008, 18h39   #4
Rob Biedenharn
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: including general variables in modules

On Mar 12, 2008, at 12:17 PM, Mario Ruiz wrote:
> But I need it.
>
> Rob Biedenharn wrote:
>> On Mar 12, 2008, at 11:49 AM, Mario Ruiz wrote:
>>
>>> $bab="hiddenmodulevalue"
>>> ...
>>> Thanks.

>> Uh, stop using global variables?
>>
>> -Rob




Do you really?

Perhaps you can describe your "need" and get a better answer, but why
not something like:

==> scenarios.rb <==
module Scenarios
module Default
def bab; "defaultmodulevalue"; end
end
module DefaultHidden
def bab; "hiddenmodulevalue"; end
end
module DefaultSecond
def bab; "secondmodulevalue"; end
end
end
__END__

==> these.rb <==
require 'scenarios'
class ThisOne
include Scenarios:efault
end

class ThatOne
include Scenarios:efaultSecond
end

puts "ThisOne has #{ThisOne.new.bab}"
puts "ThatOne has #{ThatOne.new.bab}"
__END__


-Rob

Rob Biedenharn http://agileconsultingllc.com
Rob@AgileConsultingLLC.com



  Réponse avec citation
 
Page generated in 0,06407 seconds with 9 queries