Class: Object
- Inherits:
-
BasicObject
- Defined in:
- lib/core_extensions/object.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/core_extensions/object.rb', line 18
def method_missing(method, *args, &block)
if Object.const_defined?('Platform') && Platform.respond_to?(method)
Platform.send method, *args, &block
else
super
end
end
|
Class Method Details
.find_all_descendents_of(parent_klass) ⇒ Object
2
3
4
|
# File 'lib/core_extensions/object.rb', line 2
def self.find_all_descendents_of(parent_klass)
ObjectSpace.each_object(Class).select { |klass| klass < parent_klass }
end
|
Instance Method Details
#present? ⇒ Boolean
10
11
12
13
14
15
16
|
# File 'lib/core_extensions/object.rb', line 10
def present?
if respond_to? :blank?
!blank?
else
!nil?
end
end
|
#try(method) ⇒ Object
6
7
8
|
# File 'lib/core_extensions/object.rb', line 6
def try(method)
send method rescue nil
end
|