Module: CloudCostTracker::Extensions::FogModel

Included in:
Fog::Model
Defined in:
lib/cloud_cost_tracker/extensions/fog_model.rb

Overview

Adds convenience methods to Fog::Model instances for tracking billing info

Instance Method Summary collapse

Instance Method Details

#billing_codesArray [<String>, <String>]

Returns this resource’s billing codes

Returns:

  • (Array [<String>, <String>])


28
29
30
31
# File 'lib/cloud_cost_tracker/extensions/fog_model.rb', line 28

def billing_codes
  @_billng_codes ||= Array.new
  @_billng_codes
end

#code(key, value) ⇒ Object

Adds a billing code to this cloud computing resource (Has no effect if the identical key is alreay set)

Parameters:

  • key (String)

    the key for the desired billing code

  • value (String)

    the value for the desired billing code



10
11
12
13
14
15
# File 'lib/cloud_cost_tracker/extensions/fog_model.rb', line 10

def code(key, value)
  @_billng_codes ||= Array.new
  if not @_billng_codes.include?([key, value])
    @_billng_codes.push [key, value]
  end
end

#remove_code(key, value) ⇒ Object

Adds a billing code to this cloud computing resource (Has no effect if the identical key is alreay set)

Parameters:

  • key (String)

    the key for the desired billing code

  • value (String)

    the value for the desired billing code



21
22
23
24
# File 'lib/cloud_cost_tracker/extensions/fog_model.rb', line 21

def remove_code(key, value)
  @_billng_codes ||= Array.new
  @_billng_codes.delete [key, value]
end