class Dry::Generators::StructGenerator
Public Instance Methods
check_requirements()
click to toggle source
# File lib/generators/dry/struct/struct_generator.rb, line 8 def check_requirements raise 'NAME must be provided' unless file_name.present? end
copy_spec()
click to toggle source
# File lib/generators/dry/struct/struct_generator.rb, line 22 def copy_spec if Dir.exist? File.join(Rails.root, 'spec') spec_path = File.join(SPEC_PATH, 'structs') path = File.join(spec_path, "#{@name}_spec.rb") template 'struct_spec_template.rb', path end end
copy_struct()
click to toggle source
# File lib/generators/dry/struct/struct_generator.rb, line 17 def copy_struct path = File.join(STRUCTS_PATH, "#{@name}.rb") template 'struct_template.rb', path end
copy_test()
click to toggle source
# File lib/generators/dry/struct/struct_generator.rb, line 30 def copy_test if Dir.exist? File.join(Rails.root, 'test') test_path = File.join(TEST_PATH, 'structs') path = File.join(test_path, "#{@name}_test.rb") template 'struct_test_template.rb', path end end
set_instance_variables()
click to toggle source
# File lib/generators/dry/struct/struct_generator.rb, line 12 def set_instance_variables @name = file_name.underscore @class_name = "#{@name.camelize}" end