Sha256: 7cc8e5340e0800e345f880c963524ee6b4d545854138993c73d3ee812ad31c44

Contents?: true

Size: 969 Bytes

Versions: 14

Compression:

Stored size: 969 Bytes

Contents

module Origen
  # Methods related to individual users and groups
  module Users
    autoload :User,   'origen/users/user'
    autoload :LDAP,   'origen/users/ldap'

    def app_users
      # Had to do some shenanigans here due to Origen.root not being available
      # when this file is included, only load the users from the app once a user
      # method is first called
      return @app_users if @app_users
      require File.join(Origen.root, 'config', 'users')
      @app_users = users
    end

    # Returns a user object representing the current user, will return a default
    # user object if the current user is not known to the generator
    def current_user
      core_id = Origen::Users::User.current_user_id
      user = app_users.find { |user| user.core_id == core_id }
      user || User.new(core_id)
    end

    # Returns all admin user objects
    def admins
      app_users.select(&:admin?)
    end
    alias_method :developers, :admins
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
origen-0.2.2 lib/origen/users.rb
origen-0.2.1 lib/origen/users.rb
origen-0.2.0 lib/origen/users.rb
origen-0.1.3 lib/origen/users.rb
origen-0.1.2 lib/origen/users.rb
origen-0.1.1 lib/origen/users.rb
origen-0.1.0 lib/origen/users.rb
origen-0.0.9 lib/origen/users.rb
origen-0.0.8 lib/origen/users.rb
origen-0.0.6 lib/origen/users.rb
origen-0.0.5 lib/origen/users.rb
origen-0.0.4 lib/origen/users.rb
origen-0.0.3 lib/origen/users.rb
origen-0.0.2 lib/origen/users.rb