lib/scrivito/basic_widget.rb in scrivito_sdk-0.65.2 vs lib/scrivito/basic_widget.rb in scrivito_sdk-0.66.0.rc1
- old
+ new
@@ -19,17 +19,17 @@
# This method can be overridden in subclasses to control to which pages or
# widgets the given widget class can be added. This method can be used
# to ensure that only a special type of widget can be added to a specific
# container. An example for this is a +TabGroupWidget+ that should
# contain widgets of the +TabWidget+ type only, and, vice versa, a +TabWidget+
- # should only be contained in a +TabGroupWidget+. A value of +nil+ means that
+ # should only be contained in a +TabGroupWidget+. A value of +NilClass+ means that
# no additional restrictions are applied.
#
# This method only further restricts the list of valid classes defined
# by means of {AttributeContent#valid_widget_classes_for}.
#
- # @return [Array<String, Symbol, Class>, nil]
+ # @return [NilClass, Array<Class>]
#
# @example
# class TabGroupWidget < Widget
# def valid_widget_classes_for(field_name)
# [TabWidget]
@@ -44,12 +44,13 @@
#
def self.valid_container_classes
end
def self.valid_inside_container?(container_class)
- valid_container_classes.nil? ||
- valid_container_classes.map(&:to_s).include?(container_class.name)
+ computed_classes = assert_classes(valid_container_classes, '.valid_container_classes')
+
+ computed_classes.nil? || computed_classes.include?(container_class)
end
attr_accessor :container, :container_attribute_name
attr_writer :obj, :id
@@ -200,10 +201,9 @@
# Please use {Scrivito::BasicWidget#destroy Widget#destroy} to destroy them.
# @note This method does not support +Widget+s, which are +deleted+.
# Please use {Scrivito::BasicObj#revert Obj#revert} to restore them.
#
# @raise [ScrivitoError] If the current workspace is +published+.
- # @raise [ScrivitoError] If the current workspace is the +rtc+ workspace.
# @raise [ScrivitoError] If the +Widget+ is +new+.
# @raise [ScrivitoError] If the +Widget+ is +deleted+.
#
def revert
workspace.assert_revertable