Module: Origin::Extensions::Boolean::ClassMethods

Defined in:
lib/origin/extensions/boolean.rb

Instance Method Summary collapse

Instance Method Details

#evolve(object) ⇒ true, false

Evolve the value into a boolean value stored in MongoDB. Will return true for any of these values: true, t, yes, y, 1, 1.0.

Examples:

Evolve the value to a boolean.

Boolean.evolve(true)

Since:

  • 1.0.0



20
21
22
23
24
# File 'lib/origin/extensions/boolean.rb', line 20

def evolve(object)
  __evolve__(object) do |obj|
    obj.to_s =~ (/(true|t|yes|y|1|1.0)$/i) ? true : false
  end
end