Class: ArSync::TypesGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/ar_sync/types/types_generator.rb

Instance Method Summary collapse

Instance Method Details

#generate_typescript_filesObject



6
7
8
9
10
11
12
# File 'lib/generators/ar_sync/types/types_generator.rb', line 6

def generate_typescript_files
  dir = ::Rails.root.join output_dir
  schema_class = (schema_class_name || 'SyncSchema').constantize
  args = [output_dir, *schema_class_name].map { |a| Shellwords.escape a }
  comment = "// generated by: rails generate ar_sync:types #{args.join(' ')}\n\n"
  ArSync::TypeScript.generate_typed_files schema_class, dir: dir, comment: comment
end