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.7.2 lib/souls/cli/delete/application.rb
souls-1.7.1 lib/souls/cli/delete/application.rb
souls-1.7.0 lib/souls/cli/delete/application.rb
souls-1.6.15 lib/souls/cli/delete/application.rb
souls-1.6.14 lib/souls/cli/delete/application.rb
souls-1.6.13 lib/souls/cli/delete/application.rb
souls-1.6.12 lib/souls/cli/delete/application.rb
souls-1.6.11 lib/souls/cli/delete/application.rb
souls-1.6.10 lib/souls/cli/delete/application.rb
souls-1.6.9 lib/souls/cli/delete/application.rb
souls-1.6.8 lib/souls/cli/delete/application.rb
souls-1.6.7 lib/souls/cli/delete/application.rb
souls-1.6.6 lib/souls/cli/delete/application.rb
souls-1.6.5 lib/souls/cli/delete/application.rb
souls-1.6.4 lib/souls/cli/delete/application.rb
souls-1.6.3 lib/souls/cli/delete/application.rb
souls-1.6.2 lib/souls/cli/delete/application.rb
souls-1.6.1 lib/souls/cli/delete/application.rb
souls-1.6.0 lib/souls/cli/delete/application.rb
souls-1.5.7 lib/souls/cli/delete/application.rb