lib/ecoportal/api/internal/account.rb in ecoportal-api-0.4.3 vs lib/ecoportal/api/internal/account.rb in ecoportal-api-0.5.0
- old
+ new
@@ -1,21 +1,19 @@
module Ecoportal
module API
class Internal
class Account < Common::BaseModel
passthrough :policy_group_ids, :landing_page_id, :permissions_preset, :permissions_custom,
- :preferences, :prefilter, :filter_tags, :login_provider_ids, :starred_ids, :accept_eula,
+ :preferences, :prefilter, :login_provider_ids, :starred_ids, :accept_eula,
:send_invites, :default_tag
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 :preferences, klass: :preferences_class
- VALID_TAG_REGEX = /^[A-Za-z0-9 &_'\/-]+$/
-
# Sets the `permissions_preset`.
# @note basically the same as `permissions_preset=` but when `"custom"`, it's changed to `nil`
# @param value [nil, String] preset name.
def preset=(value)
self.permissions_preset = value == "custom" ? nil : value
@@ -24,25 +22,9 @@
# Gets the `permissions_preset`.
# @note basically the same as `permissions_preset` but when 'nil', it returns `"custom"` instead
# @return [nil, String] preset name.
def preset
self.permissions_preset.nil? ? "custom" : self.permissions_preset
- end
-
- # Validates the string tags of the array, and sets the `filter_tags` property of the account.
- # @note all is set in upper case.
- # @raise [Exception] if there was any invalid string tag.
- # @param value [Array<String>] array of tags.
- def filter_tags=(value)
- unless value.is_a?(Array)
- raise "filter_tags= needs to be passed an Array, got #{value.class}"
- end
- doc["filter_tags"] = value.map do |tag|
- unless tag.match(VALID_TAG_REGEX)
- raise "Invalid filter tag #{tag.inspect}"
- end
- tag.upcase
- end
end
def as_json
super.tap do |hash|
if preset == "custom"