Class: CrontabRb::Database
- Inherits:
-
Object
- Object
- CrontabRb::Database
- Defined in:
- lib/crontab_rb/database.rb
Constant Summary collapse
- CRONTABRB =
'crontab_rb'- @@pstore =
PStore.new("#{CrontabRb.configuration.path_storage}#{CRONTABRB}.pstore")
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Database
constructor
A new instance of Database.
- #save ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Database
Returns a new instance of Database.
11 12 13 14 15 16 17 18 19 |
# File 'lib/crontab_rb/database.rb', line 11 def initialize(={}) = {} [:id] = [:id] || SecureRandom.uuid [:name] = [:name] [:command] = [:command] [:time] = [:time] [:at] = [:at] [:updated_at] = Time.now.strftime("%Y-%m-%d %H:%M:%S") end |
Class Method Details
.all ⇒ Object
25 26 27 28 29 |
# File 'lib/crontab_rb/database.rb', line 25 def self.all @@pstore.transaction(true) do @@pstore.roots.map {|root| @@pstore[root]} end end |
.create(options = {}) ⇒ Object
21 22 23 |
# File 'lib/crontab_rb/database.rb', line 21 def self.create(={}) new().save end |
.delete(name) ⇒ Object
37 38 39 40 41 |
# File 'lib/crontab_rb/database.rb', line 37 def self.delete(name) @@pstore.transaction do @@pstore.delete(name) end end |
.find(name) ⇒ Object
31 32 33 34 35 |
# File 'lib/crontab_rb/database.rb', line 31 def self.find(name) @@pstore.transaction(true) do @@pstore[name] end end |
Instance Method Details
#save ⇒ Object
43 44 45 46 47 48 |
# File 'lib/crontab_rb/database.rb', line 43 def save @@pstore.transaction do @@pstore[[:id]] = end end |