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