class Ecoportal::API::Internal::Person
@attr account [Account, nil] the account of the person or `nil` if missing.
Public Instance Methods
account=(value)
click to toggle source
Sets the Account
to the person, depending on the paramter received:
- `nil`: blanks the account. - `Account`: sets a copy of the object param as account. - `Hash`: slices the properties of `Account` (keeping the value of `user_id` if there was already account).
@note this method does not make dirty the account (meaning that `as_json` will be an empty hash `{}`) @param value [nil, Account
, Hash] value to be set. @return [nil, Account] the resulting `Account` set to the person.
# File lib/ecoportal/api/internal/person.rb, line 25 def account=(value) case value when NilClass doc["account"] = nil when Internal::Account doc["account"] = JSON.parse(value.to_json) when Hash user_id = account.user_id if account doc["account"] = value.slice(*Internal::Account::PROPERTIES) doc["account"]["user_id"] = user_id if user_id else # TODO raise "Invalid set on account: Need nil, Account or Hash; got #{value.class}" end remove_instance_variable("@account") if defined?(@account) return account end
add_account()
click to toggle source
Adds an empty account to the person. @note if the person exists, and does not have an account, an this will send an invite. @note this will not change the account properties of this person.
# File lib/ecoportal/api/internal/person.rb, line 46 def add_account self.account = {} end
as_json()
click to toggle source
Calls superclass method
# File lib/ecoportal/api/internal/person.rb, line 10 def as_json super.update("account" => account&.as_json) end
as_update(ref = :last, ignore: [])
click to toggle source
Calls superclass method
# File lib/ecoportal/api/internal/person.rb, line 14 def as_update(ref = :last, ignore: []) super(ref, ignore: ignore | ["user_id", "permissions_merged", "prefilter"]) end