Skip to content

Commit

Permalink
moved rails specific loading to railtie
Browse files Browse the repository at this point in the history
  • Loading branch information
mrhardikjoshi committed Dec 29, 2023
1 parent 2141635 commit f8fcec5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docs/activegraph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
END
end

gsub_file 'config/application.rb', "require 'rails'", ''
gsub_file 'config/application.rb', 'require "rails"', ''

generator = %q[
# Enable ActiveGraph generators, e.g: rails generate model Admin --parent User
Expand Down
11 changes: 0 additions & 11 deletions lib/active_graph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,6 @@
require 'sorted_set'
require 'yaml'

if defined?(Rails)
# Need the action_dispatch railtie to have action_dispatch.rescue_responses initialized correctly
require 'action_dispatch/railtie'
require 'rails/generators'
require 'rails/generators/active_model'
require 'rails/generators/named_base'
require 'rails/railtie'
require File.expand_path('rails/generators/migration_helper.rb', __dir__)
end

loader = Zeitwerk::Loader.for_gem
loader.ignore(File.expand_path('rails', __dir__))
loader.ignore(File.expand_path('active_graph/railtie.rb', __dir__))
Expand All @@ -48,6 +38,5 @@
Neo4j::Driver::Types::Node.wrapper_callback(&ActiveGraph::Node::Wrapping.method(:wrapper))
Neo4j::Driver::Types::Relationship.wrapper_callback(&ActiveGraph::Relationship::Wrapping.method(:wrapper))
SecureRandom.singleton_class.prepend ActiveGraph::SecureRandomExt
Rails::Generators::GeneratedAttribute.include ActiveGraph::Generators::GeneratedAttribute if defined?(Rails)

load 'active_graph/tasks/migration.rake'
11 changes: 11 additions & 0 deletions lib/active_graph/railtie.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
require 'active_graph'

if defined?(Rails)
# Need the action_dispatch railtie to have action_dispatch.rescue_responses initialized correctly
require 'action_dispatch/railtie'
require 'rails/generators'
require 'rails/generators/active_model'
require 'rails/generators/named_base'
require 'rails/railtie'
require File.expand_path('../rails/generators/migration_helper.rb', __dir__)
end
Rails::Generators::GeneratedAttribute.include ActiveGraph::Generators::GeneratedAttribute if defined?(Rails)

module ActiveGraph
class Railtie < ::Rails::Railtie
def empty_config
Expand Down

0 comments on commit f8fcec5

Please sign in to comment.