Module: Datamappify::Data::Provider::CommonProvider::ModuleMethods
- Defined in:
- lib/datamappify/data/provider/common_provider.rb
Instance Method Summary collapse
-
#class_name ⇒ String
Non-namespaced class name.
-
#find_or_build_record_class(source_class_name) ⇒ Class
Finds or builds a data record class from the data provider.
-
#load_criterias ⇒ void
Loads all the criteria files from the data provider.
- #path_name ⇒ String
-
#records_namespace ⇒ Module
private
The namespace for the data records, e.g.
Instance Method Details
#class_name ⇒ String
Non-namespaced class name
22 23 24 |
# File 'lib/datamappify/data/provider/common_provider.rb', line 22 def class_name @class_name ||= name.demodulize end |
#find_or_build_record_class(source_class_name) ⇒ Class
Finds or builds a data record class from the data provider
37 38 39 40 41 42 43 |
# File 'lib/datamappify/data/provider/common_provider.rb', line 37 def find_or_build_record_class(source_class_name) if records_namespace.const_defined?(source_class_name, false) records_namespace.const_get(source_class_name) else build_record_class(source_class_name) end end |
#load_criterias ⇒ void
This method returns an undefined value.
Loads all the criteria files from the data provider
15 16 17 |
# File 'lib/datamappify/data/provider/common_provider.rb', line 15 def load_criterias Dir[Datamappify.root.join("data/criteria/#{path_name}/*.rb")].each { |file| require file } end |
#path_name ⇒ String
27 28 29 |
# File 'lib/datamappify/data/provider/common_provider.rb', line 27 def path_name @path_name ||= class_name.underscore end |
#records_namespace ⇒ Module (private)
The namespace for the data records, e.g. Datamappify::Data::Record::ActiveRecord
50 51 52 |
# File 'lib/datamappify/data/provider/common_provider.rb', line 50 def records_namespace @records_namespace ||= Data::Record.const_set(class_name, Module.new) end |