lib/scrivito/user.rb in scrivito_sdk-1.5.5 vs lib/scrivito/user.rb in scrivito_sdk-1.6.0.rc1

- old
+ new

@@ -106,10 +106,14 @@ assert_valid_user(user) user end end + def mget(*ids) + ids.map(&method(:find)) + end + private def define_user(id = nil) user_definition = UserDefinition.new(id) yield user_definition if block_given? @@ -222,10 +226,18 @@ # By convention, only the anonymous admin user has a +nil+ id. def system_user? id.nil? end + def as_json + { + id: id, + description: description, + explicit_rules: explicit_rules_as_json, + } + end + private def calculate_description description_proc ? description_proc.call : id end @@ -240,13 +252,17 @@ end end def sandbox_suggest_user_proc(input) suggest_users_proc.call(input) - rescue Exception => e + rescue StandardError => e message = %{Method `suggest_users' of the user "#{id}" raised an error on input "#{input}"} Warning.error(message, e) nil + end + + def explicit_rules_as_json + @explicit_rules.map { |(adverb, verb, _)| "#{adverb}-#{verb}" } end end end