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
-
#do_or_do_not(name, *args) ⇒ Object?
Do or do not, there is no try.
-
#you_must(name, *args) ⇒ Object?
You must unlearn what you have learned.
Instance Method Details
#do_or_do_not(name, *args) ⇒ Object?
Do or do not, there is no try. – Yoda.
21 22 23 24 |
# File 'lib/mongoid/extensions/object/yoda.rb', line 21 def do_or_do_not(name, *args) return nil unless name respond_to?(name) ? send(name, *args) : nil end |
#you_must(name, *args) ⇒ Object?
You must unlearn what you have learned. – Yoda
38 39 40 |
# File 'lib/mongoid/extensions/object/yoda.rb', line 38 def you_must(name, *args) frozen? ? nil : do_or_do_not(name, *args) end |