Class: ActsAsApprovableGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- ActsAsApprovableGenerator
- Includes:
- ActsAsApprovable::Generators::Base
- Defined in:
- lib/generators/acts_as_approvable/acts_as_approvable_generator.rb
Instance Method Summary collapse
- #add_routes ⇒ Object
- #check_class_collisions ⇒ Object
- #create_controller_file ⇒ Object
- #create_initializer_file ⇒ Object
- #create_migration_file ⇒ Object
- #create_script_files ⇒ Object
Instance Method Details
#add_routes ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/generators/acts_as_approvable/acts_as_approvable_generator.rb', line 51 def add_routes resource = [] resource << 'resources :approvals, :only => [:index] do' resource << ' collection do' resource << ' get \'index\'' resource << ' get \'history\'' resource << ' get \'mine\'' if owner? resource << ' end' resource << ' member do' resource << ' post \'approve\'' resource << ' post \'reject\'' resource << ' post \'assign\'' if owner? resource << ' end' resource << ' end' route(resource.join("\n")) end |
#check_class_collisions ⇒ Object
16 17 18 |
# File 'lib/generators/acts_as_approvable/acts_as_approvable_generator.rb', line 16 def check_class_collisions class_collisions '', 'ApprovalsController' end |
#create_controller_file ⇒ Object
20 21 22 |
# File 'lib/generators/acts_as_approvable/acts_as_approvable_generator.rb', line 20 def create_controller_file template 'approvals_controller.rb', File.join('app/controllers', 'approvals_controller.rb') end |
#create_initializer_file ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/generators/acts_as_approvable/acts_as_approvable_generator.rb', line 29 def create_initializer_file initializer('acts_as_approvable.rb') do data = '' if owner? data << 'ActsAsApprovable::Ownership.configure' data << "(:owner => #{owner})" if owner != 'User' end data << "\n" end end |
#create_migration_file ⇒ Object
24 25 26 27 |
# File 'lib/generators/acts_as_approvable/acts_as_approvable_generator.rb', line 24 def create_migration_file number = ActiveRecord::Generators::Base.next_migration_number('db/migrate') template 'create_approvals.rb', "db/migrate/#{number}_create_approvals.rb" end |
#create_script_files ⇒ Object
42 43 44 45 46 47 |
# File 'lib/generators/acts_as_approvable/acts_as_approvable_generator.rb', line 42 def create_script_files return unless scripts? template 'jquery.form.js', 'public/javascripts/jquery.form.js' template 'approvals.js', 'public/javascripts/approvals.js' end |