Class: Effective::Generators::ViewsGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Effective::Generators::ViewsGenerator
- Includes:
- Helpers
- Defined in:
- lib/generators/effective/views_generator.rb
Instance Method Summary collapse
- #assign_attributes ⇒ Object
- #create_views ⇒ Object
- #invoke_views ⇒ Object
- #validate_resource ⇒ Object
Instance Method Details
#assign_attributes ⇒ Object
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_views ⇒ Object
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_views ⇒ Object
28 29 30 |
# File 'lib/generators/effective/views_generator.rb', line 28 def invoke_views say_status :invoke, :views, :white end |
#validate_resource ⇒ Object
19 20 21 |
# File 'lib/generators/effective/views_generator.rb', line 19 def validate_resource exit unless resource_valid? end |