solnic / virtus

[DISCONTINUED ] Attributes on Steroids for Plain Old Ruby Objects
MIT License
3.77k stars 228 forks source link

boolean_map #258

Closed lfender6445 closed 10 years ago

lfender6445 commented 10 years ago

From the README:

YupNopeBooleans = Virtus.model { |mod|
  mod.coerce = true
  mod.string.boolean_map = { 'yup' => true, 'nope' => false }
}

I would get undefined method string for Virtus::Configuration...

But I managed to get it working by going deeper on the object.

mod.coercer.config.string.boolean_map = { 'yup' => true, 'nope' => false }

Is there a mistake in the readme or am I missing something?

solnic commented 10 years ago

That's an error in the readme ;(

On Wed, Apr 2, 2014 at 9:21 PM, Luke Fender notifications@github.com wrote:

From the readme:

YupNopeBooleans = Virtus.model { |mod|
  mod.coerce = true
  mod.string.boolean_map = { 'yup' => true, 'nope' => false }
}

I would get undefined method string for Virtus::Configuration... But I managed to get it working by going deeper on the object.

mod.coercer.config.string.boolean_map = { 'yup' => true, 'nope' => false }

Is this intentional?

Reply to this email directly or view it on GitHub: https://github.com/solnic/virtus/issues/258

lfender6445 commented 10 years ago

https://github.com/solnic/virtus/pull/259