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?
108 109 110 |
# File 'lib/sequel_core/core_ext.rb', line 108 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
113 114 115 |
# File 'lib/sequel_core/core_ext.rb', line 113 def is_one_of?(*classes) !!classes.find{|c| is_a?(c)} end |
#meta_def(name, &block) ⇒ Object
Add methods to the object’s metaclass
118 119 120 |
# File 'lib/sequel_core/core_ext.rb', line 118 def (name, &block) {define_method(name, &block)} end |
#meta_eval(&block) ⇒ Object
Evaluate the block in the context of the object’s metaclass
123 124 125 |
# File 'lib/sequel_core/core_ext.rb', line 123 def (&block) .instance_eval(&block) end |
#metaclass ⇒ Object
The hidden singleton lurks behind everyone
128 129 130 131 132 |
# File 'lib/sequel_core/core_ext.rb', line 128 def class << self self end end |