Class: Ecoportal::API::Internal::Account
- Inherits:
-
Common::BaseModel
- Object
- Common::BaseModel
- Ecoportal::API::Internal::Account
- Defined in:
- lib/ecoportal/api/internal/account.rb
Constant Summary collapse
- PROPERTIES =
%w[ user_id policy_group_ids default_tag prefilter permissions_custom permissions_merged preferences login_provider_ids starred_ids landing_page_id accept_eula send_invites force_send_invites ].freeze
Instance Attribute Summary
Attributes inherited from Common::BaseModel
Instance Method Summary collapse
- #as_json ⇒ Object
- #as_update(ref = :last, ignore: []) ⇒ Object
-
#default_tag=(value) ⇒ String?
Sets the
default_tag
of the user. -
#login_provider_ids ⇒ Array<String>
The login provider ids of this user.
-
#login_provider_ids=(value) ⇒ Object
Sets the
login_provider_ids
. -
#permissions_custom=(value) ⇒ Object
It preserves the values of keys that are not defined in
value
. -
#policy_group_ids ⇒ Array<String>
The policy group ids of this user.
-
#policy_group_ids=(value) ⇒ Object
Sets the
policy_group_ids
. -
#preferences=(value) ⇒ Object
It preserves the values of keys that are not defined in
value
. -
#starred_ids ⇒ Array<String>
The starred page ids of this user.
-
#starred_ids=(value) ⇒ Object
Sets the
starred_ids
.
Methods inherited from Common::BaseModel
#consolidate!, #dirty?, #doc, embeds_one, #initial_doc, #initialize, #original_doc, passthrough, #print_pretty, #replace_doc!, #replace_original_doc!, #reset!, #to_json
Methods included from Common::BaseClass
#class_resolver, #redef_without_warning, #resolve_class
Constructor Details
This class inherits a constructor from Ecoportal::API::Common::BaseModel
Instance Method Details
#as_json ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/ecoportal/api/internal/account.rb', line 84 def as_json super.tap do |hash| hash["permissions_custom"] = .as_json hash["permissions_merged"] = perms_merged.as_json hash["preferences"] = preferences.as_json end end |
#as_update(ref = :last, ignore: []) ⇒ Object
92 93 94 |
# File 'lib/ecoportal/api/internal/account.rb', line 92 def as_update(ref = :last, ignore: []) super(ref, ignore: ignore | %w[user_id permissions_merged prefilter]) end |
#default_tag=(value) ⇒ String?
it upcases the value
Sets the default_tag
of the user
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ecoportal/api/internal/account.rb', line 25 def default_tag=(value) unless !value || value.is_a?(String) raise ArgumentError, "default_tag= needs to be passed a String or nil, got #{value.class}" end if value unless value.match(Ecoportal::API::V1::Person::VALID_TAG_REGEX) raise ArgumentError, "Invalid default tag #{value.inspect}" end value = value.upcase end doc["default_tag"] = value end |
#login_provider_ids ⇒ Array<String>
Returns the login provider ids of this user.
56 57 58 |
# File 'lib/ecoportal/api/internal/account.rb', line 56 def login_provider_ids doc["login_provider_ids"] ||= [] end |
#login_provider_ids=(value) ⇒ Object
Sets the login_provider_ids
51 52 53 |
# File 'lib/ecoportal/api/internal/account.rb', line 51 def login_provider_ids=(value) set_uniq_array_keep_order("login_provider_ids", value) end |
#permissions_custom=(value) ⇒ Object
It preserves the values of keys that are not defined in value
.
72 73 74 75 |
# File 'lib/ecoportal/api/internal/account.rb', line 72 def (value) doc["permissions_custom"] ||= {} doc["permissions_custom"].merge!(value) end |
#policy_group_ids ⇒ Array<String>
Returns the policy group ids of this user.
46 47 48 |
# File 'lib/ecoportal/api/internal/account.rb', line 46 def policy_group_ids doc["policy_group_ids"] ||= [] end |
#policy_group_ids=(value) ⇒ Object
it preserves the original order
Sets the policy_group_ids
41 42 43 |
# File 'lib/ecoportal/api/internal/account.rb', line 41 def policy_group_ids=(value) set_uniq_array_keep_order("policy_group_ids", value) end |
#preferences=(value) ⇒ Object
It preserves the values of keys that are not defined in value
.
79 80 81 82 |
# File 'lib/ecoportal/api/internal/account.rb', line 79 def preferences=(value) doc["preferences"] ||= {} doc["preferences"].merge!(value) end |
#starred_ids ⇒ Array<String>
Returns the starred page ids of this user.
66 67 68 |
# File 'lib/ecoportal/api/internal/account.rb', line 66 def starred_ids doc["starred_ids"] ||= [] end |
#starred_ids=(value) ⇒ Object
Sets the starred_ids
61 62 63 |
# File 'lib/ecoportal/api/internal/account.rb', line 61 def starred_ids=(value) set_uniq_array_keep_order("starred_ids", value) end |