Sha256: b9d37acae09d6efd219f25a989f5150bfe9dfe14ccb8b0e871dc881a63ee089d

Contents?: true

Size: 1.93 KB

Versions: 83

Compression:

Stored size: 1.93 KB

Contents

module Souls
  class Delete < Thor
    desc "scaffold [CLASS_NAME]", "Delete Scaffold"
    method_option :rbs, type: :boolean, aliases: "--rbs", default: false, desc: "Deletes Only RBS Files"
    def scaffold(class_name)
      singularized_class_name = class_name.singularize
      if options[:rbs]
        run_rbs_scaffold(class_name: singularized_class_name)
      else
        run_scaffold(class_name: singularized_class_name)
      end
      true
    rescue Thor::Error => e
      raise(Thor::Error, e)
    end

    desc "scaffold_all", "Delete Scaffold All Tables from schema.rb"
    method_option :rbs, type: :boolean, aliases: "--rbs", default: false, desc: "Deletes Only RBS Files"
    def scaffold_all
      puts(Paint["Delete All Scaffold Files!\n", :cyan])
      Souls.get_tables.each do |table|
        if options[:rbs]
          Souls::Delete.new.invoke(:scaffold, [table.singularize], { rbs: options[:rbs] })
        else
          Souls::Delete.new.invoke(:scaffold, [table.singularize], {})
        end
      end
      true
    rescue Thor::Error => e
      raise(Thor::Error, e)
    end

    private

    def run_scaffold(class_name: "user")
      type(class_name)
      type_rbs(class_name)
      query(class_name)
      query_rbs(class_name)
      mutation(class_name)
      mutation_rbs(class_name)
      policy(class_name)
      policy_rbs(class_name)
      edge(class_name)
      edge_rbs(class_name)
      connection(class_name)
      connection_rbs(class_name)
      resolver(class_name)
      resolver_rbs(class_name)
      rspec_factory(class_name)
      rspec_mutation(class_name)
      rspec_query(class_name)
      rspec_resolver(class_name)
      rspec_policy(class_name)
    end

    def run_rbs_scaffold(class_name: "user")
      type_rbs(class_name)
      query_rbs(class_name)
      mutation_rbs(class_name)
      policy_rbs(class_name)
      edge_rbs(class_name)
      connection_rbs(class_name)
      resolver_rbs(class_name)
    end
  end
end

Version data entries

83 entries across 83 versions & 1 rubygems

Version Path
souls-1.0.4 lib/souls/cli/delete/application.rb
souls-1.0.3 lib/souls/cli/delete/application.rb
souls-1.0.2 lib/souls/cli/delete/application.rb
souls-1.0.1 lib/souls/cli/delete/application.rb
souls-1.0.0 lib/souls/cli/delete/application.rb
souls-0.71.7 lib/souls/cli/delete/application.rb
souls-0.71.6 lib/souls/cli/delete/application.rb
souls-0.71.5 lib/souls/cli/delete/application.rb
souls-0.71.4 lib/souls/cli/delete/application.rb
souls-0.71.3 lib/souls/cli/delete/application.rb
souls-0.71.2 lib/souls/cli/delete/application.rb
souls-0.71.1 lib/souls/cli/delete/application.rb
souls-0.71.0 lib/souls/cli/delete/application.rb
souls-0.70.8 lib/souls/cli/delete/application.rb
souls-0.70.7 lib/souls/cli/delete/application.rb
souls-0.70.6 lib/souls/cli/delete/application.rb
souls-0.70.5 lib/souls/cli/delete/application.rb
souls-0.70.4 lib/souls/cli/delete/application.rb
souls-0.70.3 lib/souls/cli/delete/application.rb
souls-0.70.2 lib/souls/cli/delete/application.rb