Class: Alchemy::Generators::EssenceGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Alchemy::Generators::EssenceGenerator
- Defined in:
- lib/rails/generators/alchemy/essence/essence_generator.rb
Instance Method Summary collapse
- #act_as_essence ⇒ Object
- #copy_templates ⇒ Object
- #create_model ⇒ Object
- #init ⇒ Object
- #show_todo ⇒ Object
Instance Method Details
#act_as_essence ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rails/generators/alchemy/essence/essence_generator.rb', line 19 def act_as_essence essence_class_file = "app/models/#{@essence_name}.rb" essence_class = @essence_name.classify inject_into_class essence_class_file, essence_class, <<-CLASSMETHOD acts_as_essence( # Your options: # # ingredient_column: [String or Symbol] - Specifies the column name you use for storing the content in the database. (Default :body) # validate_column: [String or Symbol] - Which column should be validated. (Default: ingredient_column) # preview_text_column: [String or Symbol] - Specifies the column for the preview_text method. (Default: ingredient_column) # preview_text_method: [String or Symbol] - A method called on ingredient to get the preview text. (Default: ingredient_column) ) CLASSMETHOD end |
#copy_templates ⇒ Object
34 35 36 37 38 |
# File 'lib/rails/generators/alchemy/essence/essence_generator.rb', line 34 def copy_templates essence_name = @essence_name.classify.demodulize.underscore template "view.html.erb", "#{@essence_view_path}/_#{essence_name}_view.html.erb" template "editor.html.erb", "#{@essence_view_path}/_#{essence_name}_editor.html.erb" end |
#create_model ⇒ Object
15 16 17 |
# File 'lib/rails/generators/alchemy/essence/essence_generator.rb', line 15 def create_model invoke("model", [@essence_name]) end |
#init ⇒ Object
10 11 12 13 |
# File 'lib/rails/generators/alchemy/essence/essence_generator.rb', line 10 def init @essence_name = essence_name.underscore @essence_view_path = 'app/views/alchemy/essences' end |
#show_todo ⇒ Object
40 41 42 43 44 |
# File 'lib/rails/generators/alchemy/essence/essence_generator.rb', line 40 def show_todo say "\nPlease open the generated migration file and add your columns to your table." say "Then run 'rake db:migrate' to update your database." say "Also check the generated view files and alter them to fit your needs." end |