Class: Riddl::Utils::Notifications::Producer::Backend::Sub

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby/riddl/utils/notifications_producer.rb

Overview

{{{

Instance Method Summary collapse

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

#deleteObject



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_sObject



71
72
73
# File 'lib/ruby/riddl/utils/notifications_producer.rb', line 71

def to_s
  File.read(@name)
end