Sha256: ed59424ff05c82f0d8301880aa1dcb9337dd137efc655a854503daee1ecf8f8d

Contents?: true

Size: 669 Bytes

Versions: 2

Compression:

Stored size: 669 Bytes

Contents

module Cream
  class << self
    attr_accessor :available_roles  
  end
  
  module Role
    def self.available
      return Cream.available_roles if Cream.available_roles.present?
      return Cream.roles if Cream.roles.present?
      if defined? ::Role
        ::Role.all.map(&:name).to_symbols
      elsif defined? ::User
        ::User.roles.to_symbols
      else
        raise %q{Available roles could not be determined. Please do either of the following:\n
1) Create a Cream.setup block
2) Set Cream.available_roles explicitly
3) Create Role instances and ensure a call to Role.all returns them
4) Set User.roles explicitly
}          
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cream-0.7.3 lib/cream/role.rb
cream-0.7.2 lib/cream/role.rb