Sha256: 13930e874009d3d1c327b6b012e98300387a1db98e54d78f9a28293281e682af

Contents?: true

Size: 1.39 KB

Versions: 2

Compression:

Stored size: 1.39 KB

Contents

module Cream::Generators 
  module Config
    module Helpers

      ORM_MAP = {
        :data_mapper  => 'dm-devise',
        :mongo_mapper => 'mm-devise',
        :mongoid      => 'rails3-mongoid-devise'                
      }

      # rails generate ...
      def rgen command
        execute "rails g #{command}"
      end        

      def execute command
        logger.debug command
        run command
      end        

      def strategy
        options[:strategy]      
      end

      def logfile
        options[:logfile]      
      end

      def users 
        extra_users = admin_user? ? :admin : nil
        @users ||= ([:user] + extra_users).compact
      end

      def roles
        @roles ||= options[:roles].join(' ')
      end

      def roles_generator
        "#{orm}:roles"
      end

      def user_generator 
        active_record? ? "#{orm}:devise" : 'devise'
      end

      def active_record? 
        orm == 'active_record'
      end

      def orm
        options[:orm]
      end

      def default_roles?
        options[:default_roles]
      end

      def roles_config?
        options[:roles_config]
      end

      def permission_config?
        options[:permission_config]
      end

      def admin_user?
        options[:admin]
      end

      def here
        File.dirname(__FILE__)
      end

      def root_dir
        File.dirname(__FILE__).up(4)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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