Class: Class
Instance Method Summary collapse
-
#descendants(fast = false) ⇒ Object
Get all class descendants ‘ApplicationModel.descendants # get all DB models`.
-
#source_location(as_folder = false) ⇒ Object
OrgsController.source_location -> ./apps/controllers/orgs_controller.rb.
Instance Method Details
#descendants(fast = false) ⇒ Object
Get all class descendants ‘ApplicationModel.descendants # get all DB models`
5 6 7 8 9 10 11 12 13 |
# File 'lib/overload/class.rb', line 5 def descendants fast = false ObjectSpace.each_object(Class).select do |klass| if fast klass < self else klass.ancestors.include?(self) end end - [self] end |
#source_location(as_folder = false) ⇒ Object
OrgsController.source_location -> ./apps/controllers/orgs_controller.rb
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/overload/class.rb', line 16 def source_location as_folder=false root = Lux.root.to_s for name in instance_methods(false) src = instance_method(name).source_location.first.split(root)[1] || next src = '.%s' % src return as_folder ? File.dirname(src) : src end nil end |