Class: Blacklight::AccessControlsGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Blacklight::AccessControlsGenerator
- Defined in:
- lib/generators/blacklight/access_controls_generator.rb
Instance Method Summary collapse
- #add_access_controls_to_catalog_controller ⇒ Object
- #add_access_controls_to_user ⇒ Object
- #add_cancan_ability ⇒ Object
- #add_configuration ⇒ Object
Instance Method Details
#add_access_controls_to_catalog_controller ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/generators/blacklight/access_controls_generator.rb', line 28 def add_access_controls_to_catalog_controller say_status('status', 'ADDING ACCESS CONTROLS TO CATALOG CONTROLLER', :yellow) string_to_insert = <<-ADDITIONS include Blacklight::AccessControls::Catalog # Apply the blacklight-access_controls before_action :enforce_show_permissions, only: :show ADDITIONS insert_into_file 'app/controllers/catalog_controller.rb', string_to_insert, after: "include Blacklight::Catalog\n" end |
#add_access_controls_to_user ⇒ Object
21 22 23 24 25 26 |
# File 'lib/generators/blacklight/access_controls_generator.rb', line 21 def add_access_controls_to_user say_status('status', 'ADDING ACCESS CONTROLS TO USER MODEL', :yellow) insert_into_file File.join('app', 'models', "#{[:user_model].underscore}.rb"), " include Blacklight::AccessControls::User\n\n", after: "include Blacklight::User\n" end |
#add_cancan_ability ⇒ Object
43 44 45 46 |
# File 'lib/generators/blacklight/access_controls_generator.rb', line 43 def add_cancan_ability say_status('status', 'ADDING CANCAN ABILITY', :yellow) copy_file 'ability.rb', 'app/models/ability.rb' end |
#add_configuration ⇒ Object
48 49 50 51 |
# File 'lib/generators/blacklight/access_controls_generator.rb', line 48 def add_configuration say_status('status', 'ADDING BLACKLIGHT ACCESS CONTROLS CONFIGURATION', :yellow) copy_file 'blacklight_access_controls.rb', 'config/initializers/blacklight_access_controls.rb' end |