Class: Rolify::Generators::UserGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Rolify::Generators::UserGenerator
- Defined in:
- lib/generators/rolify/user_generator.rb
Instance Method Summary collapse
- #inject_rolify_method ⇒ Object
- #inject_user_content ⇒ Object
- #model_path ⇒ Object
- #role_association ⇒ Object
Instance Method Details
#inject_rolify_method ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/generators/rolify/user_generator.rb', line 18 def inject_rolify_method if .orm == :active_record /class #{class_name.camelize}\n|class #{class_name.camelize} .*\n|class #{class_name.demodulize.camelize}\n|class #{class_name.demodulize.camelize} .*\n/ else /include Mongoid::Document\n|include Mongoid::Document .*\n/ end end |
#inject_user_content ⇒ Object
12 13 14 15 16 |
# File 'lib/generators/rolify/user_generator.rb', line 12 def inject_user_content inject_into_file(model_path, :after => inject_rolify_method) do " rolify#{role_association}\n" end end |
#model_path ⇒ Object
26 27 28 |
# File 'lib/generators/rolify/user_generator.rb', line 26 def model_path File.join("app", "models", "#{file_path}.rb") end |
#role_association ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/generators/rolify/user_generator.rb', line 30 def role_association if role_cname != "Role" " :role_cname => '#{role_cname.camelize}'" else "" end end |