Add aliases for accessing attributes via [] and []=
This also fixes accessing attributes via symbol name and tests to ensure that such does not break in the future.
This commit is contained in:
1 parent
b8fd8670df
commit
d40baf0c72
2 files changed
+27
-5
No files matched your search
@@ -91,6 +91,8 @@ module Oga
|
||||
found ? found.value : nil
|
||||
end
|
||||
|
||||
alias_method :[], :get
|
||||
|
||||
# Adds a new attribute to the element.
|
||||
#
|
||||
# @param [Oga::XML::Attribute] attribute
|
||||
@@ -113,11 +115,7 @@ module Oga
|
||||
if found
|
||||
found.value = value
|
||||
else
|
||||
if name.include?(':')
|
||||
ns, name = name.split(':')
|
||||
else
|
||||
ns = nil
|
||||
end
|
||||
name, ns = split_name(name)
|
||||
|
||||
attr = Attribute.new(
|
||||
:name => name,
|
||||
@@ -129,6 +127,8 @@ module Oga
|
||||
end
|
||||
end
|
||||
|
||||
alias_method :[]=, :set
|
||||
|
||||
# Removes an attribute from the element.
|
||||
#
|
||||
# @param [String] name The name (optionally including namespace prefix)
|
||||
|
||||
Reference in new issue
Block a user