Class: Daidan::Generators::ResourceGenerator
- Inherits:
-
Object
- Object
- Daidan::Generators::ResourceGenerator
- Defined in:
- lib/daidan/generators/resource_generator.rb
Constant Summary collapse
- VALID_TYPES =
%w[string decimal float integer].freeze
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(resource, fields) ⇒ ResourceGenerator
constructor
A new instance of ResourceGenerator.
Constructor Details
#initialize(resource, fields) ⇒ ResourceGenerator
Returns a new instance of ResourceGenerator.
8 9 10 11 12 |
# File 'lib/daidan/generators/resource_generator.rb', line 8 def initialize(resource, fields) @resource = resource.downcase @class_name = @resource.capitalize @fields = fields end |
Instance Method Details
#generate ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/daidan/generators/resource_generator.rb', line 14 def generate parse_fields(@fields) validate_inputs generate_migration generate_model generate_mutations generate_type inject_mutation_type inject_query_type puts "✅ Generated resource: #{@resource}" end |