lib/rasn1/model.rb in rasn1-0.6.2 vs lib/rasn1/model.rb in rasn1-0.6.3
- old
+ new
@@ -312,17 +312,17 @@
end
end
# @return [String]
def inspect(level=0)
- ' ' * level + "#{@root} (#{type}) #{root.inspect(-level)}"
+ ' ' * level + "(#{type}) #{root.inspect(-level)}"
end
# Objects are equal if they have same class AND same DER
# @param [Base] other
# @return [Boolean]
- def==(other)
+ def ==(other)
(other.class == self.class) && (other.to_der == self.to_der)
end
private
@@ -370,9 +370,24 @@
if value.is_a? Hash
if obj[name].is_a? Model
initialize_elements obj[name], value
else
raise ArgumentError, "element #{name}: may only pass a Hash for Model elements"
+ end
+ elsif value.is_a? Array
+ composed = if obj[name].is_a? Model
+ obj[name].root
+ else
+ obj[name]
+ end
+ if composed.of_type.is_a? Model
+ value.each do |el|
+ composed << initialize_elements(composed.of_type.class.new, el)
+ end
+ else
+ value.each do |el|
+ obj[name] << el
+ end
end
else
obj[name].value = value
end
end