Class: Riddl::Utils::Notifications::Producer::Backend::Sub
- Inherits:
-
Object
- Object
- Riddl::Utils::Notifications::Producer::Backend::Sub
- Defined in:
- lib/ruby/riddl/utils/notifications_producer.rb
Overview
{{{
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(name) ⇒ Sub
constructor
A new instance of Sub.
- #modify(&block) ⇒ Object
- #read(&block) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name) ⇒ Sub
Returns a new instance of Sub.
59 60 61 |
# File 'lib/ruby/riddl/utils/notifications_producer.rb', line 59 def initialize(name) @name = name end |
Instance Method Details
#delete ⇒ Object
68 69 70 |
# File 'lib/ruby/riddl/utils/notifications_producer.rb', line 68 def delete FileUtils::rm_rf(File.dirname(@name)) end |
#modify(&block) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/ruby/riddl/utils/notifications_producer.rb', line 62 def modify(&block) XML::Smart.modify(@name,"<subscription xmlns='http://riddl.org/ns/common-patterns/notifications-producer/1.0'/>") do |doc| doc.register_namespace 'n', 'http://riddl.org/ns/common-patterns/notifications-producer/1.0' block.call doc end end |
#read(&block) ⇒ Object
74 75 76 77 78 79 |
# File 'lib/ruby/riddl/utils/notifications_producer.rb', line 74 def read(&block) XML::Smart.open_unprotected(@name) do |doc| doc.register_namespace 'n', 'http://riddl.org/ns/common-patterns/notifications-producer/1.0' block.call doc end end |
#to_s ⇒ Object
71 72 73 |
# File 'lib/ruby/riddl/utils/notifications_producer.rb', line 71 def to_s File.read(@name) end |