Sha256: 5d13c774272f9a77970e9cf4b179482431978c74a1ebfd248f8563abe7d719bd

Contents?: true

Size: 794 Bytes

Versions: 9

Compression:

Stored size: 794 Bytes

Contents

module Scrivito

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

  def initialize(name, type, options = {})
    @name, @type, @options = name, type, options
  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.
  #
  def values
    if type == :enum || type == :multienum
      @options[:values] || []
    end
  end
end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
scrivito_sdk-0.50.1 lib/scrivito/attribute_definition.rb
scrivito_sdk-0.50.0 lib/scrivito/attribute_definition.rb
scrivito_sdk-0.50.0.rc2 lib/scrivito/attribute_definition.rb
scrivito_sdk-0.50.0.rc1 lib/scrivito/attribute_definition.rb
scrivito_sdk-0.42.1 lib/scrivito/attribute_definition.rb
scrivito_sdk-0.42.1.rc3 lib/scrivito/attribute_definition.rb
scrivito_sdk-0.42.1.rc2 lib/scrivito/attribute_definition.rb
scrivito_sdk-0.42.1.rc1 lib/scrivito/attribute_definition.rb
scrivito_sdk-0.42.0 lib/scrivito/attribute_definition.rb