Module: Datamappify::Data::Provider::ActiveRecord

Extended by:
CommonProvider
Defined in:
lib/datamappify/data/provider/active_record.rb

Class Method Summary collapse

Methods included from CommonProvider

build_criteria, extended

Class Method Details

.build_record_association(attribute, default_source_class) ⇒ void

This method returns an undefined value.



24
25
26
27
28
29
30
31
32
# File 'lib/datamappify/data/provider/active_record.rb', line 24

def build_record_association(attribute, default_source_class)
  default_source_class.class_eval "has_one :\#{attribute.source_key}\n", __FILE__, __LINE__ + 1

  attribute.source_class.class_eval "belongs_to :\#{default_source_class.model_name.element}\n", __FILE__, __LINE__ + 1
end

.build_record_class(source_class_name) ⇒ ActiveRecord::Base

Parameters:

  • source_class_name (String)

Returns:

  • (ActiveRecord::Base)


11
12
13
14
15
16
17
18
19
20
21
# File 'lib/datamappify/data/provider/active_record.rb', line 11

def build_record_class(source_class_name)
  class_eval "module Datamappify::Data::Record::ActiveRecord\nclass \#{source_class_name} < ::ActiveRecord::Base\nself.table_name = '\#{source_class_name.pluralize.gsub('::', '_').underscore}'\nend\nend\n", __FILE__, __LINE__ + 1

  "Datamappify::Data::Record::ActiveRecord::#{source_class_name}".constantize
end

.build_record_reversed_association(attribute, default_source_class) ⇒ void

This method returns an undefined value.



35
36
37
38
39
# File 'lib/datamappify/data/provider/active_record.rb', line 35

def build_record_reversed_association(attribute, default_source_class)
  default_source_class.class_eval "belongs_to :\#{attribute.source_key}\n", __FILE__, __LINE__ + 1
end