Class: Rich::Generators::CmsAdminGenerator
- Inherits:
-
RichCms::Generators::Base
- Object
- Rails::Generators::Base
- RichCms::Generators::Base
- Rich::Generators::CmsAdminGenerator
- Includes:
- Rails::Generators::Migration, RichCms::Generators::Migration
- Defined in:
- lib/generators/rich/cms_admin/cms_admin_generator.rb
Instance Method Summary collapse
- #derive_authentication_logic ⇒ Object
- #generate_authenticated_model ⇒ Object
- #migrate ⇒ Object
- #register_authentication ⇒ Object
Methods included from RichCms::Generators::Migration
Methods inherited from RichCms::Generators::Base
Instance Method Details
#derive_authentication_logic ⇒ Object
18 19 20 21 |
# File 'lib/generators/rich/cms_admin/cms_admin_generator.rb', line 18 def derive_authentication_logic @logic = "Devise" @logic = "Authlogic" if [:authlogic] end |
#generate_authenticated_model ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/generators/rich/cms_admin/cms_admin_generator.rb', line 38 def generate_authenticated_model if [:bundle] gem @logic.underscore, {"devise" => "~> 1.1.5", "authlogic" => "~> 2.1.6"}[@logic.underscore] run "bundle install" end send :"generate_#{@logic.underscore}_assets" end |
#migrate ⇒ Object
46 47 48 |
# File 'lib/generators/rich/cms_admin/cms_admin_generator.rb', line 46 def migrate rake "db:migrate" if [:migrate] end |
#register_authentication ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/generators/rich/cms_admin/cms_admin_generator.rb', line 23 def register_authentication filename = "config/initializers/enrichments.rb" line = "Rich::Cms::Auth.setup do |config|" create_file filename unless File.exists?(filename) return if File.open(filename).readlines.collect(&:strip).include? line.strip File.open(filename, "a+") do |file| file << "#{line}\n" file << " config.logic = :#{@logic.underscore}\n" file << " config.klass = \"#{model_class_name}\"\n" file << "end" end end |