Sha256: 567729d3df0d8bfc648d6186146ebcf358f0cf0ff8f99d88199739d848dee26d

Contents?: true

Size: 975 Bytes

Versions: 1

Compression:

Stored size: 975 Bytes

Contents

module Cream::Generators 
  module Config
    module Roles
      def configure_roles
        create_roles
        set_valid_roles_cream
        use_roles_strategy        
      end      

      def roles_gems
        gem "roles_#{orm}"
      end

      def create_roles
        rgen "#{roles_generator} --strategy #{strategy} --roles #{roles} #{default_roles}"        
      end
      
      def set_valid_roles_cream
        if initializer_file? :cream
          replace_in_model_file :user, :where => /valid_roles_are\s+[(.*)]/, :with => 'valid_roles_are Cream.roles'
        end          
      end

      def use_roles_strategy
        unless read_model_file(:user) =~ /use_roles_strategy/
          insert_into_model :user do 
            "use_roles_strategy :admin_flag"
          end
        end        
      end
      
      protected
      
      def default_roles
        default_roles? ? '--default-roles' : '--no-default-roles'
      end      
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cream-0.6.3 lib/generators/cream/config/modules/roles_config.rb