Sha256: fd296d86104c3f4c4097ec4d831e83991d47cc3a489dd5461d9f807250d19aca

Contents?: true

Size: 1.11 KB

Versions: 29

Compression:

Stored size: 1.11 KB

Contents

class Eco::API::UseCases::DefaultCases::RefreshAbilitiesCase < Eco::API::Common::Loaders::UseCase
  name "refresh-abilities"
  type :transform

  # Usecase to refresh the user's account abilities as defined in the org config for their usergroups.
  # @param people [Eco::API::Organization::People] target existing _People_ of the current update.
  # @param session [Eco::API::Session] the current session where the usecase kicks in.
  # @param options [Hash] the options that modify the case behaviour or bring some dependencies.
  # @return [Void]
  def main(people, session, options, usecase)
    users    = require_users!(people, session.logger)
    update   = session.new_job("main", "update", :update, usecase, :account)
    users.each do |person|
      person.account.permissions_custom = session.new_preset(person)
      update.add(person)
    end
  end

  private

  def require_users!(people, logger)
    people.users.tap do |users|
      unless users.length > 0
        logger.warn("There are no people with account amoung your #{people.length} people")
        exit(1)
      end
    end
  end

end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
eco-helpers-2.0.16 lib/eco/api/usecases/default_cases/refresh_abilities_case.rb
eco-helpers-2.0.15 lib/eco/api/usecases/default_cases/refresh_abilities_case.rb
eco-helpers-2.0.14 lib/eco/api/usecases/default_cases/refresh_abilities_case.rb
eco-helpers-2.0.13 lib/eco/api/usecases/default_cases/refresh_abilities_case.rb
eco-helpers-2.0.12 lib/eco/api/usecases/default_cases/refresh_abilities_case.rb
eco-helpers-2.0.11 lib/eco/api/usecases/default_cases/refresh_abilities_case.rb
eco-helpers-2.0.10 lib/eco/api/usecases/default_cases/refresh_abilities_case.rb
eco-helpers-2.0.9 lib/eco/api/usecases/default_cases/refresh_abilities_case.rb
eco-helpers-2.0.8 lib/eco/api/usecases/default_cases/refresh_abilities_case.rb
eco-helpers-2.0.7 lib/eco/api/usecases/default_cases/refresh_abilities_case.rb
eco-helpers-2.0.6 lib/eco/api/usecases/default_cases/refresh_abilities_case.rb
eco-helpers-2.0.5 lib/eco/api/usecases/default_cases/refresh_abilities_case.rb
eco-helpers-2.0.4 lib/eco/api/usecases/default_cases/refresh_abilities_case.rb
eco-helpers-2.0.3 lib/eco/api/usecases/default_cases/refresh_abilities_case.rb
eco-helpers-2.0.2 lib/eco/api/usecases/default_cases/refresh_abilities_case.rb
eco-helpers-1.5.15 lib/eco/api/usecases/default_cases/refresh_abilities_case.rb
eco-helpers-1.5.14 lib/eco/api/usecases/default_cases/refresh_abilities_case.rb
eco-helpers-1.5.13 lib/eco/api/usecases/default_cases/refresh_abilities_case.rb
eco-helpers-1.5.12 lib/eco/api/usecases/default_cases/refresh_abilities_case.rb
eco-helpers-1.5.11 lib/eco/api/usecases/default_cases/refresh_abilities_case.rb