Class: PixnetSso::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- PixnetSso::InstallGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/pixnet_sso/install_generator.rb
Class Method Summary collapse
-
.next_migration_number(dirname) ⇒ Object
Implement the required interface for Rails::Generators::Migration.
Instance Method Summary collapse
- #create_migration_file ⇒ Object
- #openid_enabled ⇒ Object
- #openid_enabled? ⇒ Boolean
- #openid_model ⇒ Object
- #user_model ⇒ Object
Class Method Details
.next_migration_number(dirname) ⇒ Object
Implement the required interface for Rails::Generators::Migration. taken from github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb
12 13 14 15 16 17 18 |
# File 'lib/generators/pixnet_sso/install_generator.rb', line 12 def self.next_migration_number(dirname) #:nodoc: if ActiveRecord::Base. Time.now.utc.strftime("%Y%m%d%H%M%S") else "%.3d" % (current_migration_number(dirname) + 1) end end |
Instance Method Details
#create_migration_file ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/generators/pixnet_sso/install_generator.rb', line 20 def create_migration_file template 'user.rb', "app/models/#{user_model.singularize.underscore}.rb" migration_template 'migration.rb', "db/migrate/create_#{user_model.tableize}.rb" if openid_enabled? template 'openid_associate.rb', "app/models/#{openid_model.singularize.underscore}.rb" migration_template 'migration_openid.rb', "db/migrate/create_#{openid_model.tableize}.rb" end template 'config.rb', 'config/initializers/pixnet-sso.rb' end |
#openid_enabled ⇒ Object
42 43 44 |
# File 'lib/generators/pixnet_sso/install_generator.rb', line 42 def openid_enabled @openid_enabled ||= ask("Would you want to enable OpenID ?(y/N)") end |
#openid_enabled? ⇒ Boolean
46 47 48 |
# File 'lib/generators/pixnet_sso/install_generator.rb', line 46 def openid_enabled? openid_enabled.downcase == 'y' end |
#openid_model ⇒ Object
37 38 39 40 |
# File 'lib/generators/pixnet_sso/install_generator.rb', line 37 def openid_model return '' unless openid_enabled? @openid_model ||= ask('What is your openid model name?').classify end |
#user_model ⇒ Object
33 34 35 |
# File 'lib/generators/pixnet_sso/install_generator.rb', line 33 def user_model @user_model ||= ask('What is your user model name?').classify end |