Sha256: 6e6c108e4b4647028e3cb44ad6cd96c09d40e62a6a171072cbd007277b184429

Contents?: true

Size: 730 Bytes

Versions: 3

Compression:

Stored size: 730 Bytes

Contents

# @author Kristian Mandrup
# 
# The Operations API object
# 
# Usage example:
#   - user.roles + :admin
#   - user.roles.clear! 
#
module Troles::Common
  class Operations        
    autoload :Read,     'troles/common/operations/read'
    autoload :Write,    'troles/common/operations/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

3 entries across 3 versions & 1 rubygems

Version Path
troles-0.5.2 lib/troles/common/operations.rb
troles-0.5.1 lib/troles/common/operations.rb
troles-0.5.0 lib/troles/common/operations.rb