Sha256: bf35f764c4b187b8aed344d2d89ad45f85da54feb28b867492993b83f11a5c1b

Contents?: true

Size: 730 Bytes

Versions: 24

Compression:

Stored size: 730 Bytes

Contents

# encoding: utf-8
module Mongoid #:nodoc:
  module Extensions #:nodoc:
    module Object #:nodoc:

      # This module behaves like the master jedi.
      module Yoda #:nodoc:

        # Do or do not, there is no try. -- Yoda.
        #
        # @example Do or do not.
        #   object.do_or_do_not(:use, "The Force")
        #
        # @param [ String, Symbol ] name The method name.
        # @param [ Array ] *args The arguments.
        #
        # @return [ Object, nil ] The result of the method call or nil if the
        #   method does not exist.
        #
        # @since 2.0.0.rc.1
        def do_or_do_not(name, *args)
          respond_to?(name) ? send(name, *args) : nil
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 3 rubygems

Version Path
mongoid-2.2.0 lib/mongoid/extensions/object/yoda.rb
mongoid-2.1.9 lib/mongoid/extensions/object/yoda.rb
mongoid-2.1.8 lib/mongoid/extensions/object/yoda.rb
mongoid-2.1.7 lib/mongoid/extensions/object/yoda.rb
mongoid-2.1.6 lib/mongoid/extensions/object/yoda.rb
mongoid-2.1.5 lib/mongoid/extensions/object/yoda.rb
mongoid-2.1.4 lib/mongoid/extensions/object/yoda.rb
mongoid-2.1.3 lib/mongoid/extensions/object/yoda.rb
mongoid-2.1.2 lib/mongoid/extensions/object/yoda.rb
mongoid-2.1.1 lib/mongoid/extensions/object/yoda.rb
mongoid-2.1.0 lib/mongoid/extensions/object/yoda.rb
mongoid-braxton-2.0.2 lib/mongoid/extensions/object/yoda.rb
mongoid-2.0.2 lib/mongoid/extensions/object/yoda.rb
mongoid-2.0.1 lib/mongoid/extensions/object/yoda.rb
mongoid-2.0.0 lib/mongoid/extensions/object/yoda.rb
mongoid-2.0.0.rc.8 lib/mongoid/extensions/object/yoda.rb
mongoid-2.0.0.rc.7 lib/mongoid/extensions/object/yoda.rb
stonegao-mongoid-2.0.0.rc.6 lib/mongoid/extensions/object/yoda.rb
mongoid-2.0.0.rc.6 lib/mongoid/extensions/object/yoda.rb
mongoid-2.0.0.rc.5 lib/mongoid/extensions/object/yoda.rb