lib/ecoportal/api/internal/account.rb in ecoportal-api-0.9.7 vs lib/ecoportal/api/internal/account.rb in ecoportal-api-0.10.0
- old
+ new
@@ -1,17 +1,18 @@
module Ecoportal
module API
class Internal
class Account < Common::BaseModel
- PROPERTIES = [
- "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"
- ]
- passthrough *PROPERTIES.map(&:to_sym)
+ 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
+ passthrough(*PROPERTIES.map(&:to_sym))
+
class_resolver :preferences_class, "Ecoportal::API::Internal::Preferences"
class_resolver :permissions_class, "Ecoportal::API::Internal::Permissions"
embeds_one :permissions, key: "permissions_custom", klass: :permissions_class
embeds_one :perms_merged, key: "permissions_merged", klass: :permissions_class
@@ -21,15 +22,15 @@
# @note it upcases the value
# @param value [String, nil] the tag
# @return [String, nil] the value set in `default_tag`
def default_tag=(value)
unless !value || value.is_a?(String)
- raise ArgumentError.new("default_tag= needs to be passed a String or nil, got #{value.class}")
+ 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.new("Invalid default tag #{value.inspect}")
+ raise ArgumentError, "Invalid default tag #{value.inspect}"
end
value = value.upcase
end
doc["default_tag"] = value
end
@@ -87,10 +88,10 @@
hash["preferences"] = preferences.as_json
end
end
def as_update(ref = :last, ignore: [])
- super(ref, ignore: ignore | ["user_id", "permissions_merged", "prefilter"])
+ super(ref, ignore: ignore | %w[user_id permissions_merged prefilter])
end
end
end
end
end