[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Module, requires, and attr

dkmd_nielsen

11/27/2006 11:35:00 PM

I'm looking for the best method of coding. I have module. "module
Standards." It consists of production standard constants and methods
that will be called from all over the place. It is gem'd, and is
implemented with a require method. I would like to change some of the
constants over to accessor variables, so I can change certain settings
on the fly (for testing purposes.) I would like the accessor variable
to have a default value, but I don't know to accomplish this. (Can I
even have accessor variables/methods in a module?) I would like to get
things as simple as this:

attr :lpClientDrive, true # like to have default value here
....
def lpClientDrive=(dr)
@lpClientDrive = dr
end

What I currently have (without ability to update) is

def lpClientDrive; "//server/folder/foo/"; end

For testing purposes, I would like to re assign the client drive, as
testing will be done on a non-production machine.

3 Answers

dblack

11/28/2006 12:01:00 AM

0

dblack

11/28/2006 12:08:00 AM

0

dkmd_nielsen

11/28/2006 12:28:00 AM

0

Thank you very much. This is the kind of information I need to learn.
Thanks for everything.
dvn

dblack@wobblini.net wrote:
> Hi --
>
> On Tue, 28 Nov 2006, dblack@wobblini.net wrote:
>
> > def lpClientDrive=(dr)
> > @lpClientDriver ||= dr
>
> Ignore the || there; I meant just = .
>
>
> David
>
> --
> David A. Black | dblack@wobblini.net
> Author of "Ruby for Rails" [1] | Ruby/Rails training & consultancy [3]
> DABlog (DAB's Weblog) [2] | Co-director, Ruby Central, Inc. [4]
> [1] http://www.manning... | [3] http://www.rubypoweran...
> [2] http://dablog.r... | [4] http://www.rubyc...