# File lib/chef/openid_registration.rb, line 142 def self.cdb_list(*args) list(*args) end
Set up our CouchDB design document
# File lib/chef/openid_registration.rb, line 168 def self.create_design_document(couchdb=nil) couchdb ||= Chef::CouchDB.new couchdb.create_design_document("registrations", DESIGN_DOCUMENT) end
Whether or not there is an OpenID Registration with this key.
# File lib/chef/openid_registration.rb, line 152 def self.has_key?(name) Chef::CouchDB.new.has_key?("openid_registration", name) end
Create a Chef::Node from JSON
# File lib/chef/openid_registration.rb, line 120 def self.json_create(o) me = new me.name = o["name"] me.salt = o["salt"] me.password = o["password"] me.validated = o["validated"] me.admin = o["admin"] me.couchdb_rev = o["_rev"] if o.has_key?("_rev") me end
List all the Chef::OpenIDRegistration objects in the CouchDB. If inflate is set to true, you will get the full list of all registration objects. Otherwise, you'll just get the IDs
# File lib/chef/openid_registration.rb, line 133 def self.list(inflate=false) rs = Chef::CouchDB.new.list("registrations", inflate) if inflate rs["rows"].collect { |r| r["value"] } else rs["rows"].collect { |r| r["key"] } end end
Load an OpenIDRegistration by name from CouchDB
# File lib/chef/openid_registration.rb, line 147 def self.load(name) Chef::CouchDB.new.load("openid_registration", name) end
Create a new Chef::OpenIDRegistration object.
# File lib/chef/openid_registration.rb, line 82 def initialize() @name = nil @salt = nil @password = nil @validated = false @admin = false @couchdb_rev = nil @couchdb = Chef::CouchDB.new end
Remove this OpenIDRegistration from the CouchDB
# File lib/chef/openid_registration.rb, line 157 def destroy @couchdb.delete("openid_registration", @name, @couchdb_rev) end
# File lib/chef/openid_registration.rb, line 92 def name=(n) @name = n.gsub(/\./, '_') end
Save this OpenIDRegistration to the CouchDB
# File lib/chef/openid_registration.rb, line 162 def save results = @couchdb.store("openid_registration", @name, self) @couchdb_rev = results["rev"] end
Set the password for this object.
# File lib/chef/openid_registration.rb, line 97 def set_password(password) @salt = generate_salt @password = encrypt_password(@salt, password) end
Serialize this object as a hash
# File lib/chef/openid_registration.rb, line 103 def to_json(*a) attributes = Hash.new recipes = Array.new result = { 'name' => @name, 'json_class' => self.class.name, 'salt' => @salt, 'password' => @password, 'validated' => @validated, 'admin' => @admin, 'chef_type' => 'openid_registration', } result["_rev"] = @couchdb_rev if @couchdb_rev result.to_json(*a) end
Generated with the Darkfish Rdoc Generator 2.