Class: Monocle::Generators::MatviewGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/monocle/generators/matview_generator.rb

Instance Method Summary collapse

Instance Method Details

#generate_model_fileObject



19
20
21
22
23
24
# File 'lib/monocle/generators/matview_generator.rb', line 19

def generate_model_file
  # Don't do anything if we're skipping this
  return if options[:skip_model]
  # Invoke rails' nifty model generator for us
  invoke "model", [file_path.singularize], options.merge(migration: false, test_framework: false)
end

#generate_sql_fileObject



8
9
10
11
12
13
14
15
16
17
# File 'lib/monocle/generators/matview_generator.rb', line 8

def generate_sql_file
  create_file "db/views/#{file_name}.sql" do
<<-EOF
-- Timestamp: #{Time.now}
CREATE MATERIALIZED VIEW #{file_name} AS
-- Add your stuff here
;
EOF
  end
end