class Restforce::DB::Registry
Restforce::DB::Registry
is responsible for keeping track of all mappings established in the system.
Public Class Methods
<<(mapping)
click to toggle source
Public: Add a mapping to the overarching Mapping
collection. Appends the mapping to the collection for both its database and salesforce object types.
mapping - A Restforce::DB::Mapping
.
Returns nothing.
# File lib/restforce/db/registry.rb, line 43 def self.<<(mapping) [mapping.database_model, mapping.salesforce_model].each do |model| collection[model] << mapping end end
[](model)
click to toggle source
Public: Get the Restforce::DB::Mapping
entry for the specified model.
model - A String or Class.
Returns a Restforce::DB::Mapping
.
# File lib/restforce/db/registry.rb, line 16 def self.[](model) collection[model] end
clean!()
click to toggle source
Public: Clear out any existing registered mappings.
Returns nothing.
# File lib/restforce/db/registry.rb, line 52 def self.clean! @collection = nil end
collection()
click to toggle source
Public: Get the collection of currently-registered mappings.
Returns a Hash.
# File lib/restforce/db/registry.rb, line 59 def self.collection @collection ||= Hash.new { |h, k| h[k] = [] } end
each() { |mapping| ... }
click to toggle source
Public: Iterate through all registered Restforce::DB::Mappings.
Yields one Mapping
for each database-to-Salesforce mapping. Returns nothing.
# File lib/restforce/db/registry.rb, line 24 def self.each collection.each do |model, mappings| # Since each mapping is inserted twice, we ignore the half which # were inserted via Salesforce model names. next unless model.is_a?(Class) mappings.each do |mapping| yield mapping end end end