Class: Ows::Query::Generators::CreateGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/ows/query/create/create_generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(args, *_options) ⇒ CreateGenerator

Returns a new instance of CreateGenerator.



11
12
13
14
15
16
# File 'lib/generators/ows/query/create/create_generator.rb', line 11

def initialize(args, *_options)
  super

  @query_name = args[0].camelize
  @model_name = args[1].camelize
end

Instance Method Details

#create_queryObject



18
19
20
21
22
# File 'lib/generators/ows/query/create/create_generator.rb', line 18

def create_query
  create_file Rails.root.join("app/queries/#{file_name}_query.rb"),
              sample_file.gsub('{{QUERY_NAME}}', query_name)
                         .gsub('{{MODEL_NAME}}', model_name)
end