summaryrefslogtreecommitdiff
path: root/libraries/default.rb
blob: 66cbc42dec0fe13de50fbca50f220ab480c44a6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
class Chef
  class Provider
    class WindowsFeature
      module Base

        def action_install
          unless installed?
            install_feature(@new_resource.feature_name)
            @new_resource.updated_by_last_action(true)
            Chef::Log.info("#{@new_resource} installed feature")
          else
            Chef::Log.debug("#{@new_resource} is already installed - nothing to do")
          end
        end

        def action_remove
          if installed?
            remove_feature(@new_resource.feature_name)
            @new_resource.updated_by_last_action(true)
            Chef::Log.info("#{@new_resource} removed")
          else
            Chef::Log.debug("#{@new_resource} feature does not exist - nothing to do")
          end
        end

        def install_feature(name)
          raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :install"
        end

        def remove_feature(name)
          raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :remove"
        end

        def installed?
          raise Chef::Exceptions::Override, "You must override installed? in #{self.to_s}"
        end
      end
    end
  end
end