Class: Inetmgr::IisObject
- Inherits:
-
Object
- Object
- Inetmgr::IisObject
- Defined in:
- lib/inetmgr/iis_object.rb
Overview
IIS artifacts like Site, Application and VirtualDirectory.
Direct Known Subclasses
Application, ApplicationPool, AutoStartProvider, BindingInformation, PeriodicRestart, ProcessModel, Recycling, Site, SiteLimit, SiteLogFile, VirtualDirectory
Class Method Summary collapse
- .child(name, element_name, type) ⇒ Object
-
.children(name, item_name, type) ⇒ Object
Creates a collection property with the specified name.
-
.collection(name, item_name, type) ⇒ Object
Creates a collection property with the specified name.
-
.prop(name, actual_name, setter = lambda { |v| v }, reader = lambda { |v| v }) ⇒ Object
Creates a property with the specified name.
Instance Method Summary collapse
-
#initialize(element) ⇒ IisObject
constructor
A new instance of IisObject.
- #invoke_method(name) {|method| ... } ⇒ Object
Constructor Details
#initialize(element) ⇒ IisObject
Returns a new instance of IisObject.
6 7 8 |
# File 'lib/inetmgr/iis_object.rb', line 6 def initialize element @element = element end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args) ⇒ Object (private)
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/inetmgr/iis_object.rb', line 73 def method_missing(symbol, *args) name = symbol.to_s.to_camel_case if (/=$/.match(name)) @element.Properties.Item(name.sub(/=$/, '')).Value = args[0] else @element.Properties.Item(name).Value end rescue WIN32OLERuntimeError raise "property '#{symbol}' -> #{$!}" end |
Class Method Details
.child(name, element_name, type) ⇒ Object
53 54 55 56 57 |
# File 'lib/inetmgr/iis_object.rb', line 53 def self.child name, element_name, type define_method(name.to_s) do type.new @element.ChildElements.Item(element_name.to_s) end end |
.children(name, item_name, type) ⇒ Object
Creates a collection property with the specified name.
Parameters
-
name
- The name of the property to create -
item_name
- The name of the element in the configuration schema. -
type
- The collection’s item type.
47 48 49 50 51 |
# File 'lib/inetmgr/iis_object.rb', line 47 def self.children name, item_name, type define_method(name.to_s) do IisObjectCollection.new @element.ChildElements.Item(name.to_s).Collection, item_name.to_s, type end end |
.collection(name, item_name, type) ⇒ Object
Creates a collection property with the specified name.
Parameters
-
name
- The name of the property to create -
type
- The collection’s item type.
35 36 37 38 39 |
# File 'lib/inetmgr/iis_object.rb', line 35 def self.collection name, item_name, type define_method(name.to_s) do IisObjectCollection.new @element.Collection, item_name.to_s, type end end |
.prop(name, actual_name, setter = lambda { |v| v }, reader = lambda { |v| v }) ⇒ Object
Creates a property with the specified name.
Parameters
-
name
- The name of the property to create -
actual_name
- Optional, The actual name of the attribute or
element in the IIS configuration schema.
-
setter
- Optional, a lambda or proc to convert the property
value to a value in the IIS configuration schema.
-
reader
- Optional, a lambda or proc to convert the IIS
configuration value to the desired property value.
20 21 22 23 24 25 26 27 28 |
# File 'lib/inetmgr/iis_object.rb', line 20 def self.prop name, actual_name, setter = lambda { |v| v }, reader = lambda { |v| v } define_method(name.to_s) do reader.call(@element.Properties.Item(actual_name.to_s).Value) end define_method("#{name.to_s}=") do |val| @element.Properties.Item(actual_name.to_s).Value = setter.call(val) end end |
Instance Method Details
#invoke_method(name) {|method| ... } ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/inetmgr/iis_object.rb', line 59 def invoke_method name method = @element.Methods.Item(name.to_s).CreateInstance() # TODO: if block_given? change method_missing to change this: # method.Input.Properties.Item("key").Value = value # in to this: # method.key = value yield method if block_given? method.Execute() end |