Class: Infold::Views::ShowGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/infold/views/show_generator.rb

Instance Method Summary collapse

Instance Method Details

#setupObject



12
13
14
15
16
17
18
19
# File 'lib/generators/infold/views/show_generator.rb', line 12

def setup
  resource_name = name.camelize.singularize
  db_schema_file = Rails.root.join('db/schema.rb')
  db_schema = DbSchema.new(File.exist?(db_schema_file) ? File.read(db_schema_file) : nil)
  yaml = YAML.load_file(Rails.root.join("config/infold/#{resource_name.underscore}.yml"))
  resource = YamlReader.generate_resource(resource_name, yaml, db_schema)
  @writer = ShowWriter.new(resource)
end

#show_content_fileObject



29
30
31
# File 'lib/generators/infold/views/show_generator.rb', line 29

def show_content_file
  template "views/_show_content.haml", Rails.root.join("app/views/admin/#{name.underscore.pluralize}/_show_content.html.haml"), force: true
end

#show_fileObject



21
22
23
# File 'lib/generators/infold/views/show_generator.rb', line 21

def show_file
  template "views/show.html+turbo_frame.haml", Rails.root.join("app/views/admin/#{name.underscore.pluralize}/show.html+turbo_frame.haml"), force: true
end

#show_wrapper_fileObject



25
26
27
# File 'lib/generators/infold/views/show_generator.rb', line 25

def show_wrapper_file
  template "views/_show_wrapper.haml", Rails.root.join("app/views/admin/#{name.underscore.pluralize}/_show_wrapper.html.haml"), force: true
end