lib/scrivito/attribute_definition.rb in scrivito_sdk-0.50.1 vs lib/scrivito/attribute_definition.rb in scrivito_sdk-0.60.0.rc1

- old
+ new

@@ -1,38 +1,44 @@ module Scrivito # # This class represents a definition of an attribute. # -# @api private +# @api public # class AttributeDefinition # # @!attribute [r] name - # @api private - # @return [Symbol] the name of the attribute. + # @api public + # @return [String] the name of the attribute. # # @!attribute [r] type - # @api private - # @return [Symbol] the type of the attribute. + # @api public + # @return [String] the type of the attribute. # attr_reader :name, :type def initialize(name, type, options = {}) - @name, @type, @options = name, type, options + @name, @type, @options = name.to_s, type.to_s, options.with_indifferent_access end # # Allowed values for an attribute. # - # @api private - # @return [[String], nil] allowed values if type is +enum+ or +multienum+ or +nil+ otherwise. - # If no values have been specified, then an empty array will be returned. + # @api public + # @return [Array<String>] allowed values if type is +enum+ or +multienum+ or an empty array + # otherwise. If no values have been specified, then an empty array will be returned. # def values - if type == :enum || type == :multienum + if type == 'enum' || type == 'multienum' @options[:values] || [] + else + [] end + end + + def widgetlist? + type == 'widgetlist' end end end