Sha256: d50426745e53fd39bbbb58cf6f0194f179e33828704a21eefac23e283d32d006

Contents?: true

Size: 652 Bytes

Versions: 2

Compression:

Stored size: 652 Bytes

Contents

# @author Kristian Mandrup
# 
# The Operations API object
# 
# Usage example:
#   - user.roles + :admin
#   - user.roles.clear! 
#
module Troles::Common
  class Operations        
    autoload_modules :Read, :Write

    include Read
    include Write

    include Enumerable

    attr_reader :role_subject
    
    # constructor
    # @param [Object] the role subject, fx a User or UserAccount
    def initialize role_subject
      @role_subject = role_subject
    end

    # required method to act as enumerable
    # iterates and yields all roles in the role list (Symbols)
    def each
      list.each { |role| yield role }
    end        
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
troles-0.6.1 lib/troles/common/operations.rb
troles-0.6.0 lib/troles/common/operations.rb