Class: UsageRecord

Inherits:
OpenShift::UserModel
  • Object
show all
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

Instance Method Summary collapse

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_gbObject

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

#eventObject

Returns the value of attribute event.



10
11
12
# File 'app/models/usage_record.rb', line 10

def event
  @event
end

#gear_sizeObject

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_uuidObject

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_timeObject

Returns the value of attribute sync_time.



10
11
12
# File 'app/models/usage_record.rb', line 10

def sync_time
  @sync_time
end

#timeObject

Returns the value of attribute time.



10
11
12
# File 'app/models/usage_record.rb', line 10

def time
  @time
end

#usage_typeObject

Returns the value of attribute usage_type.



10
11
12
# File 'app/models/usage_record.rb', line 10

def usage_type
  @usage_type
end

#userObject

Returns the value of attribute user.



10
11
12
# File 'app/models/usage_record.rb', line 10

def user
  @user
end

#uuidObject

Returns the value of attribute uuid.



10
11
12
# File 'app/models/usage_record.rb', line 10

def uuid
  @uuid
end

Instance Method Details

#deleteObject

Deletes the usage record from the datastore



24
25
26
# File 'app/models/usage_record.rb', line 24

def delete
  super(user.)
end

#delete_by_gear_uuidObject



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., gear_uuid, usage_type)
end

#saveObject

Saves the usage record to the datastore



29
30
31
# File 'app/models/usage_record.rb', line 29

def save
  super(user.)
end