Module: ChefAPI::AclAble

Included in:
Resource::Client, Resource::Node, Resource::Role
Defined in:
lib/chef-api/aclable.rb

Instance Method Summary collapse

Instance Method Details

#aclObject



15
16
17
18
19
20
# File 'lib/chef-api/aclable.rb', line 15

def acl
  unless @acl
    load_acl
  end
  @acl
end

#acl_pathObject



3
4
5
# File 'lib/chef-api/aclable.rb', line 3

def acl_path
  resource_path + "/_acl"
end

#load_aclObject



7
8
9
10
11
12
13
# File 'lib/chef-api/aclable.rb', line 7

def load_acl
  data = self.class.connection.get(acl_path)
  # make deep copy
  @orig_acl_data = Marshal.load(Marshal.dump(data))
  data.freeze
  @acl = data
end

#save!Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/chef-api/aclable.rb', line 22

def save!
  super
  if @acl != @orig_acl_data
    %w{create update grant read delete}.each { |action|
      if @acl[action] != @orig_acl_data[action]
        url = "#{acl_path}/#{action}"
        self.class.connection.put(url, { action => @acl[action] }.to_json)
      end
    }
  end
end