Class: ActiveRecord::Generators::ErbacGenerator
- Inherits:
-
Base
- Object
- Base
- ActiveRecord::Generators::ErbacGenerator
- Defined in:
- lib/generators/active_record/erbac_generator.rb
Instance Method Summary collapse
- #copy_erbac_migration ⇒ Object
- #generate_auth_item_model ⇒ Object
- #init_erbac_options ⇒ Object
- #inject_auth_item_model ⇒ Object
Instance Method Details
#copy_erbac_migration ⇒ Object
42 43 44 |
# File 'lib/generators/active_record/erbac_generator.rb', line 42 def copy_erbac_migration migration_template "migration.rb", "db/migrate/erbac_create_auth" end |
#generate_auth_item_model ⇒ Object
30 31 32 33 |
# File 'lib/generators/active_record/erbac_generator.rb', line 30 def generate_auth_item_model Rails::Generators.invoke("active_record:model", [.auth_item[0], "--no-migration"], behavior: behavior) Rails::Generators.invoke("active_record:model", [.auth_assignment[0], "--no-migration"], behavior: behavior) end |
#init_erbac_options ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/generators/active_record/erbac_generator.rb', line 17 def # assert options.auth_item[0] .auth_item[1] ||= .auth_item[0].classify || Erbac::Configure::AUTH_ITEM_CLASS .auth_item[2] ||= .auth_item[0].tableize || Erbac::Configure::AUTH_ITEM_TABLE # assert options.auth_item_child[0] .auth_item_child[1] || .auth_item_child[0].tableize || Erbac::Configure::AUTH_ITEM_CHILD_TABLE # assert options.auth_assignment[0] .auth_assignment[1] || .auth_assignment[0].classify || Erbac::Configure::AUTH_ASSIGNMENT_CLASS .auth_assignment[2] || .auth_assignment[0].tableize || Erbac::Configure::AUTH_ASSIGNMENT_TABLE end |
#inject_auth_item_model ⇒ Object
35 36 37 38 39 40 |
# File 'lib/generators/active_record/erbac_generator.rb', line 35 def inject_auth_item_model if behavior == :invoke inject_into_class(model_path(.auth_item[0]), .auth_item[1], " control_auth_item\n") inject_into_class(model_path(.auth_assignment[0]), .auth_assignment[1], " control_auth_assignment\n") end end |