Getting config value via variable; CH.config."${variable}" possible?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting config value via variable; CH.config."${variable}" possible?

micke_
Hi

Is it possible to get config values by using variables?

The following test fails for me:

    protected void setUp() {
        super.setUp()
                mockConfig('''
                            test.it.key="hello"
                                               
                                ''')
    }
        void testBla(){
                assertEquals('hello', CH.config.test.it.key)
                def variable = 'test.it.key'
                assertEquals('hello', CH.config."${variable}") //<---- Fails
        }

Cheers,
 micke

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Getting config value via variable; CH.config."${variable}" possible?

micke_
I've noticed that it works if there isn't a dot in the config name, like :
def variable = 'hello'
assertEquals('world', CH.config."${variable}")

Can it be made to work when there is a dot in the name?

I'm using grails 1.2.1, in case there has been changes in this area.

- Micke

On 2 October 2010 16:55, Mikael Andersson <[hidden email]> wrote:

> Hi
>
> Is it possible to get config values by using variables?
>
> The following test fails for me:
>
>    protected void setUp() {
>        super.setUp()
>                mockConfig('''
>                            test.it.key="hello"
>
>                                ''')
>    }
>        void testBla(){
>                assertEquals('hello', CH.config.test.it.key)
>                def variable = 'test.it.key'
>                assertEquals('hello', CH.config."${variable}") //<---- Fails
>        }
>
> Cheers,
>  micke
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Getting config value via variable; CH.config."${variable}" possible?

Daniel Henrique Alves Lima
        Hi, Mikael. I don't know if this can help you, but i can access grails
configuration using flatConfig instead of config. Something like this:


grailsApplication.flatConfig["grails.mime.types"]

instead of

grailsApplication.config.grails.mime.types


        Will this work for CH?




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Getting config value via variable; CH.config."${variable}" possible?

micke_
That works beautifully :)

Many thanks,
 Micke


On 2 October 2010 19:01, Daniel Henrique Alves Lima
<[hidden email]> wrote:

>        Hi, Mikael. I don't know if this can help you, but i can access grails
> configuration using flatConfig instead of config. Something like this:
>
>
> grailsApplication.flatConfig["grails.mime.types"]
>
> instead of
>
> grailsApplication.config.grails.mime.types
>
>
>        Will this work for CH?
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

НА: Re: Getting config value via variable; CH.config."${variable}" possible?

ishe
In reply to this post by Daniel Henrique Alves Lima



От: Daniel Henrique Alves Lima [via Grails] <[hidden email]>
Отправлено: 2 октября 2010 г. 21:01
Кому: ig78 <[hidden email]>
Тема: Re: Getting config value via variable; CH.config."${variable}" possible?

        Hi, Mikael. I don't know if this can help you, but i can access grails
configuration using flatConfig instead of config. Something like this:


grailsApplication.flatConfig["grails.mime.types"]

instead of

grailsApplication.config.grails.mime.types


        Will this work for CH?




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





View message @ http://grails.1312388.n4.nabble.com/Getting-config-value-via-variable-CH-config-variable-possible-tp2952537p2952625.html
To start a new topic under Grails - user, email [hidden email]
To unsubscribe from Grails - user, click here.