Top Level Namespace

Defined Under Namespace

Modules: Inetmgr Classes: String

Constant Summary collapse

IisConfiguration =
Inetmgr::IisConfiguration

Instance Method Summary collapse

Instance Method Details

#create_task(taskname, task_object_proc, &execute_body) ⇒ Object


33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rake/inetmgrtask.rb', line 33

def create_task(taskname, task_object_proc, &execute_body)
  taskclass = :"Inetmgr_TaskFor_#{taskname}"
  taskmethod = taskname.to_s.downcase.to_sym

  Object.class_eval(<<-EOF, __FILE__, __LINE__)
    def #{taskmethod}(name=:#{taskname}, *args, &block)
      Inetmgr.const_get("#{taskclass}").new(name, *args, &block)
    end
  EOF

  Inetmgr.class_eval do
    const_set(taskclass, Class.new(Inetmgr::InetmgrTask) do
      define_method :execute do |name|
        task_object = task_object_proc.call

        call_task_block(task_object)
      	execute_body.call(task_object) unless execute_body.nil?
      end
    end)
  end
end