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_attributes ⇒ Object



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

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

#create_views ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/generators/effective/views_generator.rb', line 28

def create_views
  (invoked_actions & available_actions).each do |action|
    template "views/#{action}.html.haml", resource.view_file(action)
  end

  if invoked_actions.include?('show') || non_crud_actions.present?
    template 'views/_resource.html.haml', resource.view_file(resource.name, partial: true)
  end
end

#invoke_views ⇒ Object



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

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