Class: Ridley::UserObject

Inherits:
ChefObject show all
Defined in:
lib/ridley/chef_objects/user_object.rb

Instance Method Summary collapse

Methods inherited from ChefObject

#<=>, #==, chef_id, #chef_id, chef_json_class, chef_type, #eql?, #hash, #initialize, #inspect, #reload, #save, set_chef_id, set_chef_json_class, set_chef_type, #update

Constructor Details

This class inherits a constructor from Ridley::ChefObject

Instance Method Details

#authenticate(password) ⇒ Object



43
44
45
# File 'lib/ridley/chef_objects/user_object.rb', line 43

def authenticate(password)
  @resource.authenticate(self.chef_id, password)
end

#regenerate_keyBoolean

Regenerates the private key of the instantiated user object. The new private key will be set to the value of the ‘private_key’ accessor of the instantiated user object.

Returns:

  • (Boolean)

    true for success and false for failure



38
39
40
41
# File 'lib/ridley/chef_objects/user_object.rb', line 38

def regenerate_key
  self.private_key = true
  self.save
end

#to_jsonObject

Override to_json to reflect to massage the returned attributes based on the type of connection. Only OHC/OPC requires the json_class attribute is not present.



49
50
51
52
53
54
55
# File 'lib/ridley/chef_objects/user_object.rb', line 49

def to_json
  if resource.connection.hosted?
    to_hash.except(:json_class).to_json
  else
    super
  end
end