Class: Inforouter::Rules
- Inherits:
-
Object
- Object
- Inforouter::Rules
- Defined in:
- lib/inforouter/rules.rb
Instance Attribute Summary collapse
-
#rules ⇒ Object
Array of
Inforouter::RuleItems.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Rules
constructor
A new instance of Rules.
-
#to_xml ⇒ Object
The Rules XML fragment should be as described below.
Constructor Details
#initialize(params = {}) ⇒ Rules
Returns a new instance of Rules.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/inforouter/rules.rb', line 6 def initialize(params = {}) params = { :allowable_file_types => '', :checkins => false, :checkouts => false, :document_deletes => false, :folder_deletes => false, :new_documents => false, :new_folders => false, :classified_documents => false }.merge(params) @rules = [] params.each do |key, value| @rules << Inforouter::RuleItem.new( :name => key.to_s.camelize, :value => value ) end end |
Instance Attribute Details
#rules ⇒ Object
Array of Inforouter::RuleItems.
4 5 6 |
# File 'lib/inforouter/rules.rb', line 4 def rules @rules end |
Instance Method Details
#to_xml ⇒ Object
The Rules XML fragment should be as described below. The Rule item that is not specified in the xml structure will not be updated. For the AllowableFileTypes set value attribute to comman delimited file extensions or set value to “*” for allowing all file types.
<Rules>
<Rule Name="AllowableFileTypes" Value="BMP,DOC,JPG,XLS" />
<Rule Name="Checkins" Value="disallows" />
<Rule Name="Checkouts" Value="disallows" />
<Rule Name="DocumentDeletes" Value="disallows" />
<Rule Name="FolderDeletes" Value="disallows" />
<Rule Name="NewDocuments" Value="disallows" />
<Rule Name="NewFolders" Value="disallows" />
<Rule Name="ClassifiedDocuments" Value="allows" />
</Rules>
42 43 44 45 46 47 48 49 |
# File 'lib/inforouter/rules.rb', line 42 def to_xml builder = Nokogiri::XML::Builder.new do |xml| xml.Rules do rules.each { |rule| xml.Rules(rule.to_hash) } end end builder.doc.root.to_xml end |