Class: Inforouter::FolderRule

Inherits:
Object
  • Object
show all
Defined in:
lib/inforouter/folder_rule.rb

Class Method Summary collapse

Class Method Details

.rule_itme(xml, name, value) ⇒ Object



46
47
48
# File 'lib/inforouter/folder_rule.rb', line 46

def self.rule_itme(xml, name, value)
  xml.Rule(:Name => name, :Value => value)
end

.rules_xml(options = {}) ⇒ 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>



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/inforouter/folder_rule.rb', line 20

def self.rules_xml(options = {})
  options = {
    :allowable_file_types => nil,
    :checkins => 'disallows',
    :checkouts => 'disallows',
    :document_deletes => 'disallows',
    :folder_deletes => 'disallows',
    :new_documents => 'disallows',
    :new_folders => 'disallows',
    :classified_documents => 'disallows'
  }.merge(options)
  builder = Nokogiri::XML::Builder.new do |xml|
    xml.Rules {
      rule_item(xml, 'AllowableFileTypes', options[:allowable_file_types])
      rule_item(xml, 'Checkins', options[:checkins])
      rule_item(xml, 'Checkouts', options[:checkouts])
      rule_item(xml, 'DocumentDeletes', options[:document_deletes])
      rule_item(xml, 'FolderDeletes', options[:folder_deletes])
      rule_item(xml, 'NewDocuments', options[:new_documents])
      rule_item(xml, 'NewFolders', options[:new_folders])
      rule_item(xml, 'ClassifiedDocuments', options[:classified_documents])
    }
  end
  builder.doc.root.to_xml
end