Module: Mongoid::Extensions::Object::Yoda

Included in:
Object
Defined in:
lib/mongoid/extensions/object/yoda.rb

Overview

This module behaves like the master jedi.

Instance Method Summary collapse

Instance Method Details

#do_or_do_not(name, *args) ⇒ Object?

Do or do not, there is no try. – Yoda.

Examples:

Do or do not.

object.do_or_do_not(:use, "The Force")

Parameters:

Returns:

  • (Object, nil)

    The result of the method call or nil if the method does not exist.

Since:

  • 2.0.0.rc.1



21
22
23
# File 'lib/mongoid/extensions/object/yoda.rb', line 21

def do_or_do_not(name, *args)
  respond_to?(name) ? send(name, *args) : nil
end