lib/generators/roles/config/config_generator.rb in cream-0.8.4 vs lib/generators/roles/config/config_generator.rb in cream-0.8.5

- old
+ new

@@ -17,10 +17,14 @@ class_option :default_roles, :type => :boolean, :default => true, :desc => "Create default roles :admin and :guest" class_option :gems, :type => :boolean, :default => true, :desc => "Add gems to gemfile?" def configure_roles logger.add_logfile :logfile => logfile if logfile + + # make the artifactor model methods behave according to selected orm! - this is a macro + self.class.use_orm :"#{orm}" + roles_gems if gems? create_roles use_roles_strategy set_valid_roles_cream end @@ -91,11 +95,11 @@ def set_valid_roles_cream user_exist? if initializer_file? :cream if read_model(:user) =~ /valid_roles_are/ replace_in_model :user, :where => /valid_roles_are\s+[(.*)]/, :with => 'valid_roles_are Cream.roles' - else + else insert_into_model :user do "valid_roles_are Cream::Role.available" end end else @@ -106,14 +110,14 @@ def user_exist? raise "User model missing. Please create a User model before running this generator" if !model_file?(:user) end def use_roles_strategy - user_exist? + # user_exist? - unless read_model(:user) =~ /use_roles_strategy/ - inject_into_file model_file(:user), "use_roles_strategy :#{strategy}\n\n", :before => "class" - end + # unless read_model(:user) =~ /use_roles_strategy/ + # inject_into_file model_file(:user), "use_roles_strategy :#{strategy}\n\n", :before => "class" + # end end def default_roles default_roles? ? '--default-roles' : '--no-default-roles' end \ No newline at end of file