Sha256: c5df7ba6abb28fab888ffa6426985aec8dde253463d8e0fa2ad66cddf23da92e

Contents?: true

Size: 893 Bytes

Versions: 118

Compression:

Stored size: 893 Bytes

Contents

module Scrivito

#
# This class represents a collection of attribute definitions.
#
# @api public
#
class AttributeDefinitionCollection
  include Enumerable

  # Compatibility for Object#blank?
  delegate :empty?, to: :attribute_definitions

  def initialize(attribute_definitions)
    @attribute_definitions = attribute_definitions
  end

  #
  # Iterates over the attribute definitions.
  #
  # @api public
  # @yieldparam [Scrivito:AttributeDefinition] attribute_definition
  #
  def each(&block)
    attribute_definitions.values.each(&block)
  end

  #
  # Find definition of an attribute.
  #
  # @api public
  # @param name [Symbol, String] the name of the attribute.
  # @return [Scrivito::AttributeDefinition, nil] attribute definition if found or +nil+ otherwise.
  #
  def [](name)
    attribute_definitions[name.to_s]
  end

  private

  attr_reader :attribute_definitions
end

end

Version data entries

118 entries across 118 versions & 1 rubygems

Version Path
scrivito_sdk-0.71.0 lib/scrivito/attribute_definition_collection.rb
scrivito_sdk-0.71.0.rc2 lib/scrivito/attribute_definition_collection.rb
scrivito_sdk-0.71.0.rc1 lib/scrivito/attribute_definition_collection.rb
scrivito_sdk-0.70.0 lib/scrivito/attribute_definition_collection.rb
scrivito_sdk-0.70.0.rc3 lib/scrivito/attribute_definition_collection.rb
scrivito_sdk-0.70.0.rc2 lib/scrivito/attribute_definition_collection.rb
scrivito_sdk-0.70.0.rc1 lib/scrivito/attribute_definition_collection.rb
scrivito_sdk-0.66.0 lib/scrivito/attribute_definition_collection.rb
scrivito_sdk-0.66.0.rc2 lib/scrivito/attribute_definition_collection.rb
scrivito_sdk-0.65.2 lib/scrivito/attribute_definition_collection.rb
scrivito_sdk-0.66.0.rc1 lib/scrivito/attribute_definition_collection.rb
scrivito_sdk-0.65.1 lib/scrivito/attribute_definition_collection.rb
scrivito_sdk-0.65.0 lib/scrivito/attribute_definition_collection.rb
scrivito_sdk-0.65.0.rc2 lib/scrivito/attribute_definition_collection.rb
scrivito_sdk-0.65.0.rc1 lib/scrivito/attribute_definition_collection.rb
scrivito_sdk-0.60.0 lib/scrivito/attribute_definition_collection.rb
scrivito_sdk-0.60.0.rc2 lib/scrivito/attribute_definition_collection.rb
scrivito_sdk-0.60.0.rc1 lib/scrivito/attribute_definition_collection.rb