Skip to content

Commit

Permalink
ignored railtie and rails dir
Browse files Browse the repository at this point in the history
  • Loading branch information
mrhardikjoshi committed Dec 29, 2023
1 parent 9b2c160 commit 7e7917a
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 54 deletions.
7 changes: 3 additions & 4 deletions lib/active_graph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@
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
unless defined?(Rails)
loader.ignore(File.expand_path('active_graph/generators', __dir__))
loader.ignore(File.expand_path('active_graph/railtie.rb', __dir__))
end
loader.ignore(File.expand_path('rails', __dir__))
loader.ignore(File.expand_path('active_graph/railtie.rb', __dir__))
loader.inflector.inflect("ansi" => "ANSI")
loader.setup
# loader.eager_load
Expand Down
33 changes: 0 additions & 33 deletions lib/active_graph/generators/active_model.rb

This file was deleted.

17 changes: 0 additions & 17 deletions lib/active_graph/generators/generated_attribute.rb

This file was deleted.

57 changes: 57 additions & 0 deletions lib/rails/generators/migration_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
module ActiveGraph
module Generators #:nodoc:
end
end

module ActiveGraph::Generators::MigrationHelper
extend ActiveSupport::Concern

Expand Down Expand Up @@ -44,3 +49,55 @@ def migration_template(template_name, prefix = '')
FileUtils.rm(real_file_name) if @behavior == :revoke
end
end

class ActiveGraph::Generators::ActiveModel < Rails::Generators::ActiveModel #:nodoc:
def self.all(klass)
"#{klass}.all"
end

def self.find(klass, params = nil)
"#{klass}.find(#{params})"
end

def self.build(klass, params = nil)
if params
"#{klass}.new(#{params})"
else
"#{klass}.new"
end
end

def save
"#{name}.save"
end

def update_attributes(params = nil)
"#{name}.update_attributes(#{params})"
end

def errors
"#{name}.errors"
end

def destroy
"#{name}.destroy"
end
end

module ActiveGraph
module Generators
module GeneratedAttribute #:nodoc:
def type_class
case type.to_s.downcase
when 'any' then 'any'
when 'datetime' then 'DateTime'
when 'date' then 'Date'
when 'integer', 'number', 'fixnum' then 'Integer'
when 'float' then 'Float'
else
'String'
end
end
end
end
end

0 comments on commit 7e7917a

Please sign in to comment.