Class: Effective::Generators::ViewsGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Includes:
Helpers
Defined in:
lib/generators/effective/views_generator.rb

Instance Method Summary collapse

Instance Method Details

#assign_attributesObject



23
24
25
26
# File 'lib/generators/effective/views_generator.rb', line 23

def assign_attributes
  @attributes = (invoked_attributes.presence || resource_attributes).except(:archived)
  self.class.send(:attr_reader, :attributes)
end

#create_viewsObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/generators/effective/views_generator.rb', line 32

def create_views
  if invoked_actions.include?('show') || non_crud_actions.present?
    if admin_effective_scaffold?
      template "#{scaffold_path}/views/_resource.html.haml", resource.admin_effective_view_file(resource.name, partial: true)
    else
      template "#{scaffold_path}/views/_resource.html.haml", resource.view_file(resource.name, partial: true)
    end
  end

  if effective_scaffold?
    template "#{scaffold_path}/views/_layout.html.haml", resource.view_file('layout', partial: true)
  end

end

#invoke_viewsObject



28
29
30
# File 'lib/generators/effective/views_generator.rb', line 28

def invoke_views
  say_status :invoke, :views, :white
end

#validate_resourceObject



19
20
21
# File 'lib/generators/effective/views_generator.rb', line 19

def validate_resource
  exit unless resource_valid?
end