Ruby code in lwRp decalaration

Hi all,

In a LRWP resource definition (the file in ./resources), is it possible to
do something like :
actions :install
default_action :install
attribute :name, :kind_of => String, :name_attribute => true
attribute :repository, :kind_of => String, :default => node[:name
][‘repository’]

Unfortunately :name is not yet defined when my third line gets executed.
Is there a way to access it from within that file (I need it to define
other attributes default)?


Dorian JAMINAIS
System Administrator
+33 6 95 10 95 37
http://perfect-memory.com

https://twitter.com/semanticbushttp://www.facebook.com/pages/Perfect-Memory/155555567821817

You will probably have to write up a HWRP to get the kind of lazy
evaluation you want

On Fri, May 31, 2013 at 12:51 PM, Dorian Jaminais <
dorian.jaminais@perfect-memory.com> wrote:

Hi all,

In a LRWP resource definition (the file in ./resources), is it possible to
do something like :
actions :install
default_action :install
attribute :name, :kind_of => String, :name_attribute => true
attribute :repository, :kind_of => String, :default => node[:name
]['repository']

Unfortunately :name is not yet defined when my third line gets executed.
Is there a way to access it from within that file (I need it to define
other attributes default)?

--
Dorian JAMINAIS
System Administrator
+33 6 95 10 95 37
http://perfect-memory.com

https://twitter.com/semanticbushttp://www.facebook.com/pages/Perfect-Memory/155555567821817

Typically, I leave that with a default of nil in the resource attributes and conditionally set it in the provider.

~j

On 2013-05-31, at 09:51, Dorian Jaminais dorian.jaminais@perfect-memory.com wrote:

Hi all,

In a LRWP resource definition (the file in ./resources), is it possible to do something like :
actions :install
default_action :install
attribute :name, :kind_of => String, :name_attribute => true
attribute :repository, :kind_of => String, :default => node[:name]['repository']

Unfortunately :name is not yet defined when my third line gets executed.
Is there a way to access it from within that file (I need it to define other attributes default)?

--
Dorian JAMINAIS
System Administrator
+33 6 95 10 95 37

@Joseph, indeed that's what I do right now but I was wondering if it was
possible

Thanks for your answer

2013/5/31 Joseph Holsten joseph@josephholsten.com

Typically, I leave that with a default of nil in the resource attributes
and conditionally set it in the provider.

~j

On 2013-05-31, at 09:51, Dorian Jaminais <
dorian.jaminais@perfect-memory.com> wrote:

Hi all,

In a LRWP resource definition (the file in ./resources), is it possible
to do something like :
actions :install
default_action :install
attribute :name, :kind_of => String, :name_attribute => true
attribute :repository, :kind_of => String, :default =>
node[:name]['repository']

Unfortunately :name is not yet defined when my third line gets executed.
Is there a way to access it from within that file (I need it to define
other attributes default)?

--
Dorian JAMINAIS
System Administrator
+33 6 95 10 95 37

--
Dorian JAMINAIS
System Administrator
+33 6 95 10 95 37
http://perfect-memory.com

https://twitter.com/semanticbushttp://www.facebook.com/pages/Perfect-Memory/155555567821817

On Friday, May 31, 2013 at 10:16 AM, Andrew Gross wrote:

You will probably have to write up a HWRP to get the kind of lazy evaluation you want

On Fri, May 31, 2013 at 12:51 PM, Dorian Jaminais <dorian.jaminais@perfect-memory.com (mailto:dorian.jaminais@perfect-memory.com)> wrote:

Hi all,

In a LRWP resource definition (the file in ./resources), is it possible to do something like :
actions :install
default_action :install
attribute :name, :kind_of => String, :name_attribute => true
attribute :repository, :kind_of => String, :default => node[:name]['repository']
LWRPs are basically a wrapper around class_eval, so for most cases you can just add a little more traditional ruby method definition where you need it.

You only have to use HWRPs if you need full control of the Class name or its superclass.

--
Daniel DeLeo