lib/punchblock/event/complete.rb in punchblock-0.5.1 vs lib/punchblock/event/complete.rb in punchblock-0.6.0
- old
+ new
@@ -15,10 +15,15 @@
reason.component_id = component_id
end
end
end
+ def reason=(other)
+ children.map &:remove
+ self << other
+ end
+
def recording
element = find_first('//ns:recording', :ns => RAYO_NAMESPACES[:record_complete])
if element
RayoNode.import(element).tap do |recording|
recording.call_id = call_id
@@ -30,10 +35,21 @@
def inspect_attributes # :nodoc:
[:reason, :recording] + super
end
class Reason < RayoNode
+ def self.new(options = {})
+ super().tap do |new_node|
+ case options
+ when Nokogiri::XML::Node
+ new_node.inherit options
+ when Hash
+ options.each_pair { |k,v| new_node.send :"#{k}=", v }
+ end
+ end
+ end
+
def name
super.to_sym
end
def inspect_attributes # :nodoc:
@@ -52,9 +68,13 @@
class Error < Reason
register :error, :ext_complete
def details
text.strip
+ end
+
+ def details=(other)
+ self << other
end
def inspect_attributes # :nodoc:
[:details] + super
end