Sha256: 28a6af7e8cb6f56f0bd2ac159c722f02a4621344be170c6c2f929fa8889888e6
Contents?: true
Size: 1.25 KB
Versions: 19
Compression:
Stored size: 1.25 KB
Contents
class Eco::API::UseCases::Default::People::Utils::SetDefaultTagCase < Eco::API::Common::Loaders::UseCase name "set-default-tag" type :transform # take the deepest tag (the one that is further down in the tree) # different options (several nodes at the same depth): # => take the common node between them (i.e. you have Hamilton and Auckland -> take New Zealand) # => if there's no common node between them, take the `first` (unless they are at top level of the tree) def main(_people, session, options, usecase) tagtree_present! users = users_present! update = session.new_job("main", "update", :update, usecase, :account) users.each do |person| micro.refresh_default_tag(nil, person, options) update.add(person) end end private def tagtree_present! return unless tagtree? msg = "There is no locs struct defined. Aborting..." logger.fatal(msg) raise msg end def users_present! people.users.tap do |users| next if users.length.positive? msg = "There are no people with account... aborting script" log(:error) { msg } raise msg end end def tagtree? return false unless (tree = session.tagtree) !tree.empty? end end
Version data entries
19 entries across 19 versions & 1 rubygems