Sha256: 6b021a602b21658fad662ccd1d5ec84c5c4a05ea4363ded0d75080f458187f4a

Contents?: true

Size: 1.29 KB

Versions: 7

Compression:

Stored size: 1.29 KB

Contents

require 'singleton'

module CanTango
  class Configuration
    class Engines
      class Permission < Engine
        def modes
          @modes ||= [:cache]
        end

        def store &block
          @store ||= ns::Store.new
          @store.default_class = CanTango::PermissionEngine::YamlStore
          yield @store if block
          @store
        end

        def types
          [:roles, :role_groups, :licenses, :users, :user_types, :account_types]
        end

        attr_reader :config_path

        def config_path path = nil
          return current_config_path if !path
          raise "Must be a valid path to permission yaml file, was: #{path}" if !dir?(path)
          @config_path = path
        end

        alias_method :config_path=, :config_path

        private

        def valid_mode_names
          [:cache, :no_cache]
        end
 
        def current_config_path
          @config_path ||= File.join(::Rails.root.to_s, 'config') if rails?
          @config_path or raise "Define path to config files dir!\nCanTango.config.engine(:permission).config_path(dir_path)"
        end

        def rails?
          defined?(::Rails) && ::Rails.respond_to?(:root)
        end

        def dir? dir
          return false if !dir
          File.directory?(dir)
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cantango-0.9.4.7 lib/cantango/configuration/engines/permission.rb
cantango-0.9.4.6 lib/cantango/configuration/engines/permission.rb
cantango-0.9.4.5 lib/cantango/configuration/engines/permission.rb
cantango-0.9.4.3 lib/cantango/configuration/engines/permission.rb
cantango-0.9.4.2 lib/cantango/configuration/engines/permission.rb
cantango-0.9.4.1 lib/cantango/configuration/engines/permission.rb
cantango-0.9.4 lib/cantango/configuration/engines/permission.rb