LWRP Boolean

Ohai Chefs!

What’s the “correct” way to have a boolean attribute in a LWRP? There’s no Boolean class in Ruby, so

attribute :some_boolean, :kind_of => Boolean, :default => false

is not possible.

What’s the solution?

Thanks,

  • cassiano

:kind_of => [TrueClass, FalseClass]
-t

On Fri, Apr 12, 2013 at 1:56 PM, Cassiano Leal cassianoleal@gmail.comwrote:

Ohai Chefs!

What's the "correct" way to have a boolean attribute in a LWRP? There's no
Boolean class in Ruby, so

attribute :some_boolean, :kind_of => Boolean, :default => false

is not possible.

What's the solution?

Thanks,

  • cassiano

Hi Cassiano,

A common trick to implement this, which I've seen across a number of LWRPs is to do:

:kind_of => [TrueClass, FalseClass]

See also: supervisor/resources/fcgi.rb at master · poise/supervisor · GitHub

--
Graham Christensen

On Friday, April 12, 2013 at 8:56 AM, Cassiano Leal wrote:

Ohai Chefs!

What's the "correct" way to have a boolean attribute in a LWRP? There's no Boolean class in Ruby, so

attribute :some_boolean, :kind_of => Boolean, :default => false

is not possible.

What's the solution?

Thanks,

  • cassiano

:kind_of => [TrueClass, FalseClass], :default => false

did it.

Thanks, guys!

  • cassiano

On Friday, April 12, 2013 at 09:59, Graham Christensen wrote:

Hi Cassiano,

A common trick to implement this, which I've seen across a number of LWRPs is to do:

:kind_of => [TrueClass, FalseClass]

See also: supervisor/resources/fcgi.rb at master · poise/supervisor · GitHub

--
Graham Christensen

On Friday, April 12, 2013 at 8:56 AM, Cassiano Leal wrote:

Ohai Chefs!

What's the "correct" way to have a boolean attribute in a LWRP? There's no Boolean class in Ruby, so

attribute :some_boolean, :kind_of => Boolean, :default => false

is not possible.

What's the solution?

Thanks,

  • cassiano