lib/scrivito/attribute_collection.rb in scrivito_sdk-0.18.1 vs lib/scrivito/attribute_collection.rb in scrivito_sdk-0.30.0.rc1
- old
+ new
@@ -22,27 +22,22 @@
# Yields successive attributes of the collection. Implements the {Enumerable} interface.
# @api public
def_delegators :@attributes, :each
+ #
# Finds an attribute in this collection by its name.
#
# @api public
#
- # See {Scrivito::ObjClass#attributes} for example of how to find an attribute by name.
+ # @param [String] name the name of the attribute
+ # @return [Scrivito::Attribute] if there is an attribute with name +name+
+ # @return [nil] if there is no attribute with name +name+
#
- # @param [String] name
- # @return [Scrivito::Attribute]
- # @raise [Scrivito::ResourceNotFound] Raised when no attribute with the given +name+ can be found.
+ # @see Scrivito::ObjClass#attributes Examples of how to find an attribute by name.
+ #
def [](name)
- attribute = @attributes.detect { |attribute| attribute.name == name.to_s }
-
- unless attribute
- raise ResourceNotFound, "Could not find #{Attribute} with name '#{name}' for" \
- " obj class '#{@obj_class.name}'."
- end
-
- attribute
+ @attributes.detect { |attribute| attribute.name == name.to_s }
end
# Adds an attribute to this collection and updates the obj class.
#
# @api public