Skip to content

Commit

Permalink
Allow DescendantLoader methods to work w/o Rails
Browse files Browse the repository at this point in the history
Swapping out `Rails` and using the `ManageIQ` lib allows for the
DescendantLoader's instance methods to function without Rails, so the
following now works:

   ruby -Ilib -e 'require "extensions/descendant_loader.rb"; DescendantLoader.descendants_paths'
  • Loading branch information
NickLaMuro committed Jun 28, 2017
1 parent 84cb87e commit cc17416
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/extensions/descendant_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#

require "active_record"
require_relative "../manageiq"

class DescendantLoader
CACHE_VERSION = 2
Expand Down Expand Up @@ -169,7 +170,7 @@ def name_combinations(names)
# RubyParser is slow, so wrap it in a simple mtime-based cache.
module Cache
def cache_path
Rails.root.join('tmp/cache/sti_loader.yml')
ManageIQ.root.join('tmp/cache/sti_loader.yml')
end

def load_cache
Expand Down Expand Up @@ -209,7 +210,7 @@ def classes_in(filename)

module Mapper
def descendants_paths
@descendants_paths ||= [Rails.root.join("app/models")]
@descendants_paths ||= [ManageIQ.root.join("app/models")]
end

def class_inheritance_relationships
Expand Down

0 comments on commit cc17416

Please sign in to comment.