Class: Effective::Generators::FormGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Effective::Generators::FormGenerator
- Includes:
- Helpers
- Defined in:
- lib/generators/effective/form_generator.rb
Instance Method Summary collapse
- #assign_attributes ⇒ Object
- #create_default_form ⇒ Object
- #create_tabpanel_form ⇒ Object
- #invoke_form ⇒ Object
Instance Method Details
#assign_attributes ⇒ Object
20 21 22 23 |
# File 'lib/generators/effective/form_generator.rb', line 20 def assign_attributes @attributes = invoked_attributes.presence || resource_attributes self.class.send(:attr_reader, :attributes) end |
#create_default_form ⇒ Object
29 30 31 32 33 |
# File 'lib/generators/effective/form_generator.rb', line 29 def create_default_form if resource.nested_resources.blank? template 'forms/default/_form.html.haml', resource.view_file('form', partial: true) end end |
#create_tabpanel_form ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/generators/effective/form_generator.rb', line 35 def create_tabpanel_form if resource.nested_resources.present? template 'forms/tabpanel/_form.html.haml', resource.view_file('form', partial: true) template 'forms/tabpanel/_tab_fields.html.haml', resource.view_file("form_#{resource.name}", partial: true) end class_eval { attr_accessor :nested_resource } resource.nested_resources.each do |nested_resource| @nested_resource = nested_resource template 'forms/tabpanel/_tab_nested_resource.html.haml', resource.view_file("form_#{nested_resource.plural_name}", partial: true) @nested_resource = Effective::Resource.new(nested_resource) template 'forms/fields/_nested_resource_fields.html.haml', File.join('app/views', resource.namespace.to_s, (resource.namespace.present? ? '' : resource.class_path), nested_resource.name.to_s.underscore.pluralize, '_fields.html.haml') end end |
#invoke_form ⇒ Object
25 26 27 |
# File 'lib/generators/effective/form_generator.rb', line 25 def invoke_form say_status :invoke, :form, :white end |