Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/sequel_core/core_ext.rb
Overview
Helpers from Metaid and a bit more
Instance Method Summary collapse
-
#blank? ⇒ Boolean
Objects are blank if they respond true to empty?.
-
#is_one_of?(*classes) ⇒ Boolean
Returns true if the object is an instance of one of the classes.
-
#meta_def(name, &block) ⇒ Object
Add methods to the object’s metaclass.
-
#meta_eval(&block) ⇒ Object
Evaluate the block in the context of the object’s metaclass.
-
#metaclass ⇒ Object
The hidden singleton lurks behind everyone.
Instance Method Details
#blank? ⇒ Boolean
Objects are blank if they respond true to empty?
106 107 108 |
# File 'lib/sequel_core/core_ext.rb', line 106 def blank? respond_to?(:empty?) && empty? end |
#is_one_of?(*classes) ⇒ Boolean
Returns true if the object is an instance of one of the classes
111 112 113 |
# File 'lib/sequel_core/core_ext.rb', line 111 def is_one_of?(*classes) !!classes.find{|c| is_a?(c)} end |
#meta_def(name, &block) ⇒ Object
Add methods to the object’s metaclass
116 117 118 |
# File 'lib/sequel_core/core_ext.rb', line 116 def (name, &block) {define_method(name, &block)} end |
#meta_eval(&block) ⇒ Object
Evaluate the block in the context of the object’s metaclass
121 122 123 |
# File 'lib/sequel_core/core_ext.rb', line 121 def (&block) .instance_eval(&block) end |
#metaclass ⇒ Object
The hidden singleton lurks behind everyone
126 127 128 129 130 |
# File 'lib/sequel_core/core_ext.rb', line 126 def class << self self end end |