Class: Ecoportal::API::Internal::Account
- Inherits:
-
Common::BaseModel
- Object
- Common::BaseModel
- Ecoportal::API::Internal::Account
- Defined in:
- lib/ecoportal/api/internal/account.rb
Instance Attribute Summary
Attributes inherited from Common::BaseModel
Instance Method Summary collapse
- #as_json ⇒ Object
-
#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. -
#preset ⇒ nil, String
Gets the
permissions_preset. -
#preset=(value) ⇒ Object
Sets the
permissions_preset. -
#starred_ids ⇒ Array<String>
The starred page ids of this user.
-
#starred_ids=(value) ⇒ Object
Sets the
starred_ids.
Methods inherited from Common::BaseModel
#as_update, #consolidate!, #dirty?, #doc, embeds_one, #initial_doc, #initialize, #original_doc, passthrough, #print_pretty, #reset!, #to_json
Methods included from Common::BaseClass
#class_resolver, #resolve_class
Constructor Details
This class inherits a constructor from Ecoportal::API::Common::BaseModel
Instance Method Details
#as_json ⇒ Object
89 90 91 92 93 94 95 96 97 98 |
# File 'lib/ecoportal/api/internal/account.rb', line 89 def as_json super.tap do |hash| if preset == "custom" hash["permissions_custom"] = .as_json else hash.delete "permissions_custom" end hash["preferences"] = preferences.as_json end end |
#login_provider_ids ⇒ Array<String>
Returns the login provider ids of this user.
44 45 46 |
# File 'lib/ecoportal/api/internal/account.rb', line 44 def login_provider_ids doc["login_provider_ids"] ||= [] end |
#login_provider_ids=(value) ⇒ Object
Sets the login_provider_ids
36 37 38 39 40 41 |
# File 'lib/ecoportal/api/internal/account.rb', line 36 def login_provider_ids=(value) unless value.is_a?(Array) raise "login_provider_ids= needs to be passed an Array, got #{value.class}" end doc["login_provider_ids"] = value.compact end |
#permissions_custom=(value) ⇒ Object
It preserves the values of keys that are not defined in value.
77 78 79 80 |
# File 'lib/ecoportal/api/internal/account.rb', line 77 def (value) doc["permissions_custom"] ||= {} doc["permissions_custom"].merge!(value) end |
#policy_group_ids ⇒ Array<String>
Returns the policy group ids of this user.
31 32 33 |
# File 'lib/ecoportal/api/internal/account.rb', line 31 def policy_group_ids doc["policy_group_ids"] ||= [] end |
#policy_group_ids=(value) ⇒ Object
it preserves the original order
Sets the policy_group_ids
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ecoportal/api/internal/account.rb', line 18 def policy_group_ids=(value) unless value.is_a?(Array) raise "policy_group_ids= needs to be passed an Array, got #{value.class}" end value.uniq! ini_ids = (original_doc && original_doc["policy_group_ids"]) || [] # preserve original order to avoid false updates doc["policy_group_ids"] = (ini_ids & value) + (value - ini_ids) doc["policy_group_ids"].compact end |
#preferences=(value) ⇒ Object
It preserves the values of keys that are not defined in value.
84 85 86 87 |
# File 'lib/ecoportal/api/internal/account.rb', line 84 def preferences=(value) doc["preferences"] ||= {} doc["preferences"].merge!(value) end |
#preset ⇒ nil, String
basically the same as permissions_preset but when 'nil', it returns "custom" instead
Gets the permissions_preset.
71 72 73 |
# File 'lib/ecoportal/api/internal/account.rb', line 71 def preset self..nil? ? "custom" : self. end |
#preset=(value) ⇒ Object
basically the same as permissions_preset= but when "custom", it's changed to nil
Sets the permissions_preset.
64 65 66 |
# File 'lib/ecoportal/api/internal/account.rb', line 64 def preset=(value) self. = value == "custom" ? nil : value end |
#starred_ids ⇒ Array<String>
Returns the starred page ids of this user.
57 58 59 |
# File 'lib/ecoportal/api/internal/account.rb', line 57 def starred_ids doc["starred_ids"] ||= [] end |
#starred_ids=(value) ⇒ Object
Sets the starred_ids
49 50 51 52 53 54 |
# File 'lib/ecoportal/api/internal/account.rb', line 49 def starred_ids=(value) unless value.is_a?(Array) raise "starred_ids= needs to be passed an Array, got #{value.class}" end doc["starred_ids"] = value.compact end |