Class: Object

Inherits:
BasicObject
Defined in:
lib/ubiquitously/extensions/core.rb

Overview

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.overridden_methods(parent_class = Object, within_tree = true) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/ubiquitously/extensions/core.rb', line 4

def self.overridden_methods(parent_class = Object, within_tree = true)
  if within_tree
    defined_methods = ancestors[0..ancestors.index(parent_class) - 1].map { |object| object.instance_methods(false) }.flatten.uniq
    parent_methods = superclass.instance_methods
  else
    defined_methods = instance_methods(false)
    parent_methods = parent_class.instance_methods
  end
  defined_methods & parent_methods
end

.overrides?(method, parent_class = Object, within_tree = true) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/ubiquitously/extensions/core.rb', line 19

def self.overrides?(method, parent_class = Object, within_tree = true)
  overridden_methods(parent_class, within_tree).include?(method.to_s)
end

Instance Method Details

#overridden_methods(parent_class = Object, within_tree = true) ⇒ Object



15
16
17
# File 'lib/ubiquitously/extensions/core.rb', line 15

def overridden_methods(parent_class = Object, within_tree = true)
  self.class.overridden_methods(parent_class, within_tree)
end

#overrides?(method, parent_class = Object, within_tree = true) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/ubiquitously/extensions/core.rb', line 23

def overrides?(method, parent_class = Object, within_tree = true)
  self.class.overrides?(method, parent_class, within_tree)
end