class DeviseDateRestrictableGenerator
Public Class Methods
next_migration_number( dirname )
click to toggle source
# File lib/generators/devise_date_restrictable/devise_date_restrictable_generator.rb, line 12 def self.next_migration_number( dirname ) if ActiveRecord::Base.timestamped_migrations Time.now.utc.strftime( '%Y%m%d%H%M%S' ) else "%.3d" % ( current_migration_number( dirname ) + 1 ) end end
source_root()
click to toggle source
# File lib/generators/devise_date_restrictable/devise_date_restrictable_generator.rb, line 6 def self.source_root @_devise_source_root ||= File.expand_path( '../templates', __FILE__ ) end
Public Instance Methods
invoke_migration()
click to toggle source
# File lib/generators/devise_date_restrictable/devise_date_restrictable_generator.rb, line 28 def invoke_migration model_name = options['model'] @model_name = model_name.camelize.singularize if columns_exist? say "* Date restrictable columns already seem to exist on @{model_name}" else migration_template 'migration.rb', "db/migrate/devise_add_#{model_name.downcase}_date_restriction_fields.rb" end puts "\n\nMake sure to add :date_restrictable to the devise line of your #{@model_name} model file!\n\n" end
Protected Instance Methods
columns_exist?()
click to toggle source
# File lib/generators/devise_date_restrictable/devise_date_restrictable_generator.rb, line 49 def columns_exist? @model_name.constantize.column_names.include?( 'valid_from' ) and @model_name.constantize.column_names.include?( 'valid_until' ) end