Sha256: 20849852a05e640e73a62c0a52925493859edcaca7658ba5a7385f0f560ab753

Contents?: true

Size: 890 Bytes

Versions: 11

Compression:

Stored size: 890 Bytes

Contents

module Scrivito

#
# This class represents an attribute definition.
#
# @api public
#
class AttributeDefinition
  #
  # @!attribute [r] name
  #   @api public
  #   @return [String] the name of the attribute.
  #
  # @!attribute [r] type
  #   @api public
  #   @return [String] the type of the attribute.
  #
  attr_reader :name, :type

  def initialize(name, type, options = {})
    @name, @type, @options = name.to_s, type.to_s, options.with_indifferent_access
  end

  #
  # Allowed values for an attribute.
  #
  # @api public
  # @return [Array<String>] allowed values if +type+ is +enum+ or +multienum+ or an empty array
  #   otherwise. If no values have been specified, an empty array is returned.
  #
  def values
    if type == 'enum' || type == 'multienum'
      @options[:values] || []
    else
      []
    end
  end

  def widgetlist?
    type == 'widgetlist'
  end
end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
scrivito_sdk-0.70.2 lib/scrivito/attribute_definition.rb
scrivito_sdk-0.71.2 lib/scrivito/attribute_definition.rb
scrivito_sdk-0.71.1 lib/scrivito/attribute_definition.rb
scrivito_sdk-0.70.1 lib/scrivito/attribute_definition.rb
scrivito_sdk-0.71.0 lib/scrivito/attribute_definition.rb
scrivito_sdk-0.71.0.rc2 lib/scrivito/attribute_definition.rb
scrivito_sdk-0.71.0.rc1 lib/scrivito/attribute_definition.rb
scrivito_sdk-0.70.0 lib/scrivito/attribute_definition.rb
scrivito_sdk-0.70.0.rc3 lib/scrivito/attribute_definition.rb
scrivito_sdk-0.70.0.rc2 lib/scrivito/attribute_definition.rb
scrivito_sdk-0.70.0.rc1 lib/scrivito/attribute_definition.rb