Class: Cert
- Inherits:
-
CouchRest::Model::Base
- Object
- CouchRest::Model::Base
- Cert
- Defined in:
- app/models/cert.rb
Class Method Summary collapse
Instance Method Summary collapse
- #attach_zip ⇒ Object
- #set_random ⇒ Object
- #zip_attachment ⇒ Object
- #zipname ⇒ Object
- #zipped ⇒ Object
Class Method Details
.pick_from_pool ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'app/models/cert.rb', line 25 def pick_from_pool cert = self.sample || self.create! cert.destroy return cert rescue RESOURCE_NOT_FOUND retry if Cert.by_random.count > 0 raise RECORD_NOT_FOUND end |
.sample ⇒ Object
21 22 23 |
# File 'app/models/cert.rb', line 21 def sample self.by_random.startkey(rand).first || self.by_random.first end |
Instance Method Details
#attach_zip ⇒ Object
40 41 42 43 |
# File 'app/models/cert.rb', line 40 def attach_zip file = File.open(Rails.root.join("config", "cert")) self. :file => file, :name => zipname end |
#set_random ⇒ Object
36 37 38 |
# File 'app/models/cert.rb', line 36 def set_random self.random = rand end |
#zip_attachment ⇒ Object
49 50 51 |
# File 'app/models/cert.rb', line 49 def [zipname] end |
#zipname ⇒ Object
45 46 47 |
# File 'app/models/cert.rb', line 45 def zipname 'cert.txt' end |
#zipped ⇒ Object
53 54 55 |
# File 'app/models/cert.rb', line 53 def zipped (zipname) end |