Module: FogTracker::Extensions::FogModel
- Included in:
- Fog::Model
- Defined in:
- lib/fog_tracker/extensions/fog_model.rb
Overview
Adds convenience methods to Fog::Model instances for gathering information about its account, and about other Fog::Model resources
Instance Attribute Summary collapse
-
#_fog_collection_tracker ⇒ Object
a FogTracker::CollectionTracker - *do not modify* - used for #tracker_account.
-
#_query_processor ⇒ Object
a FogTracker::QueryParser - *do not modify* - used for tracker_query.
Instance Method Summary collapse
-
#account_resources(collection_name) ⇒ Array <Fog::Model>
Returns Fog::Model resources from this Resource’s account only.
-
#tracker_account ⇒ Hash
Returns a cleaned copy of the resource’s account information from the its collection tracker (credentials are removed).
-
#tracker_description ⇒ String
returns a descriptive identifier unique to this resource.
-
#tracker_query(query_string) ⇒ Array <Fog::Model>
Runs a query across all accounts using a Query::QueryProcessor.
Instance Attribute Details
#_fog_collection_tracker ⇒ Object
a FogTracker::CollectionTracker - *do not modify* - used for #tracker_account
8 9 10 |
# File 'lib/fog_tracker/extensions/fog_model.rb', line 8 def _fog_collection_tracker @_fog_collection_tracker end |
#_query_processor ⇒ Object
a FogTracker::QueryParser - *do not modify* - used for tracker_query
11 12 13 |
# File 'lib/fog_tracker/extensions/fog_model.rb', line 11 def _query_processor @_query_processor end |
Instance Method Details
#account_resources(collection_name) ⇒ Array <Fog::Model>
Returns Fog::Model resources from this Resource’s account only.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/fog_tracker/extensions/fog_model.rb', line 27 def account_resources(collection_name) results = Array.new if @_query_processor results = @_query_processor.execute( "#{tracker_account[:name]}::*::*::#{collection_name}" ) (results.each {|r| yield r}) if block_given? end results end |
#tracker_account ⇒ Hash
Returns a cleaned copy of the resource’s account information from the its collection tracker (credentials are removed).
16 17 18 19 |
# File 'lib/fog_tracker/extensions/fog_model.rb', line 16 def tracker_account (not _fog_collection_tracker) ? Hash.new : _fog_collection_tracker.clean_account_data end |
#tracker_description ⇒ String
returns a descriptive identifier unique to this resource
54 55 56 57 |
# File 'lib/fog_tracker/extensions/fog_model.rb', line 54 def tracker_description type = (self.class.name.match(/::([^:]+)$/))[1] "#{type} #{self.identity} in account #{tracker_account[:name]}" end |
#tracker_query(query_string) ⇒ Array <Fog::Model>
Runs a query across all accounts using a Query::QueryProcessor. Any code block parameter will be executed once for (and with) each resulting resource.
43 44 45 46 47 48 49 50 |
# File 'lib/fog_tracker/extensions/fog_model.rb', line 43 def tracker_query(query_string) results = Array.new if @_query_processor results = @_query_processor.execute(query_string) (results.each {|r| yield r}) if block_given? end results end |