module RD3::Repository
Public Class Methods
_map_config_file_name_to_data_provider(config_file_name)
click to toggle source
# File lib/rd3/repository.rb, line 45 def self._map_config_file_name_to_data_provider(config_file_name) provider = config_file_name.to_s.split('_').first.to_sym #@data_provider = case provider #when :mysql then RD3::DataProviders::Rdbms #when :postgresql then RD3::DataProviders::Rdbms #else raise TypeError, "#{provider} is not a supported data provider" #end case provider when :mysql then :rdbms when :postgresql then :rdbms else raise TypeError, "#{provider} is not a supported data provider" end end
config_file_name(config=nil)
click to toggle source
# File lib/rd3/repository.rb, line 7 def self.config_file_name(config=nil) return @config_file_name if @config_file_name if config # config file name must be set before including the # db provider module @config_file_name = config # derive the data provider from the # config file name (convention based) @data_provider = _map_config_file_name_to_data_provider(config) self.module_eval <<-EVAL include RD3::DataProviders::#{@data_provider.capitalize} EVAL end end
data_provider()
click to toggle source
# File lib/rd3/repository.rb, line 29 def self.data_provider @data_provider end
delete(key, opts)
click to toggle source
# File lib/rd3/repository.rb, line 41 def self.delete(key, opts) raise NotImplementedError end
find_by_key(key, opts)
click to toggle source
# File lib/rd3/repository.rb, line 33 def self.find_by_key(key, opts) raise NotImplementedError end
model()
click to toggle source
# File lib/rd3/repository.rb, line 25 def self.model @model ||= name.gsub('Repository', '').constantize end
save(l_obj)
click to toggle source
# File lib/rd3/repository.rb, line 37 def self.save(l_obj) raise NotImplementedError end