Class: UsageRecord
- Inherits:
-
OpenShift::UserModel
- Object
- OpenShift::UserModel
- UsageRecord
- Defined in:
- app/models/usage_record.rb
Constant Summary collapse
- EVENTS =
{ :begin => "begin", :end => "end", :continue => "continue" }
- USAGE_TYPES =
{ :gear_usage => "GEAR_USAGE", :addtl_fs_gb => "ADDTL_FS_GB" }
Instance Attribute Summary collapse
-
#addtl_fs_gb ⇒ Object
Returns the value of attribute addtl_fs_gb.
-
#event ⇒ Object
Returns the value of attribute event.
-
#gear_size ⇒ Object
Returns the value of attribute gear_size.
-
#gear_uuid ⇒ Object
Returns the value of attribute gear_uuid.
-
#sync_time ⇒ Object
Returns the value of attribute sync_time.
-
#time ⇒ Object
Returns the value of attribute time.
-
#usage_type ⇒ Object
Returns the value of attribute usage_type.
-
#user ⇒ Object
Returns the value of attribute user.
-
#uuid ⇒ Object
Returns the value of attribute uuid.
Instance Method Summary collapse
-
#delete ⇒ Object
Deletes the usage record from the datastore.
- #delete_by_gear_uuid ⇒ Object
-
#initialize(event = nil, user = nil, time = nil, uuid = nil, usage_type = nil) ⇒ UsageRecord
constructor
A new instance of UsageRecord.
-
#save ⇒ Object
Saves the usage record to the datastore.
Constructor Details
#initialize(event = nil, user = nil, time = nil, uuid = nil, usage_type = nil) ⇒ UsageRecord
Returns a new instance of UsageRecord.
14 15 16 17 18 19 20 21 |
# File 'app/models/usage_record.rb', line 14 def initialize(event=nil, user=nil, time=nil, uuid=nil, usage_type=nil) self.uuid = uuid ? uuid : OpenShift::Model.gen_uuid self.event = event self.time = time ? time : Time.now.utc self.user = user self.usage_type = usage_type self.sync_time = nil end |
Instance Attribute Details
#addtl_fs_gb ⇒ Object
Returns the value of attribute addtl_fs_gb.
10 11 12 |
# File 'app/models/usage_record.rb', line 10 def addtl_fs_gb @addtl_fs_gb end |
#event ⇒ Object
Returns the value of attribute event.
10 11 12 |
# File 'app/models/usage_record.rb', line 10 def event @event end |
#gear_size ⇒ Object
Returns the value of attribute gear_size.
10 11 12 |
# File 'app/models/usage_record.rb', line 10 def gear_size @gear_size end |
#gear_uuid ⇒ Object
Returns the value of attribute gear_uuid.
10 11 12 |
# File 'app/models/usage_record.rb', line 10 def gear_uuid @gear_uuid end |
#sync_time ⇒ Object
Returns the value of attribute sync_time.
10 11 12 |
# File 'app/models/usage_record.rb', line 10 def sync_time @sync_time end |
#time ⇒ Object
Returns the value of attribute time.
10 11 12 |
# File 'app/models/usage_record.rb', line 10 def time @time end |
#usage_type ⇒ Object
Returns the value of attribute usage_type.
10 11 12 |
# File 'app/models/usage_record.rb', line 10 def usage_type @usage_type end |
#user ⇒ Object
Returns the value of attribute user.
10 11 12 |
# File 'app/models/usage_record.rb', line 10 def user @user end |
#uuid ⇒ Object
Returns the value of attribute uuid.
10 11 12 |
# File 'app/models/usage_record.rb', line 10 def uuid @uuid end |
Instance Method Details
#delete ⇒ Object
Deletes the usage record from the datastore
24 25 26 |
# File 'app/models/usage_record.rb', line 24 def delete super(user.login) end |
#delete_by_gear_uuid ⇒ Object
33 34 35 |
# File 'app/models/usage_record.rb', line 33 def delete_by_gear_uuid OpenShift::DataStore.instance.delete_usage_record_by_gear_uuid(user.login, gear_uuid, usage_type) end |
#save ⇒ Object
Saves the usage record to the datastore
29 30 31 |
# File 'app/models/usage_record.rb', line 29 def save super(user.login) end |