Module: ModelSync::Base::Config
- Defined in:
- lib/model_sync.rb
Instance Attribute Summary collapse
-
#mapping_block ⇒ Object
readonly
Returns the value of attribute mapping_block.
-
#mappings ⇒ Object
readonly
Returns the value of attribute mappings.
-
#relationship ⇒ Object
readonly
Returns the value of attribute relationship.
-
#slave_model_class ⇒ Object
readonly
Returns the value of attribute slave_model_class.
-
#slave_model_name ⇒ Object
readonly
Returns the value of attribute slave_model_name.
Instance Method Summary collapse
Instance Attribute Details
#mapping_block ⇒ Object (readonly)
Returns the value of attribute mapping_block.
10 11 12 |
# File 'lib/model_sync.rb', line 10 def mapping_block @mapping_block end |
#mappings ⇒ Object (readonly)
Returns the value of attribute mappings.
10 11 12 |
# File 'lib/model_sync.rb', line 10 def mappings @mappings end |
#relationship ⇒ Object (readonly)
Returns the value of attribute relationship.
10 11 12 |
# File 'lib/model_sync.rb', line 10 def relationship @relationship end |
#slave_model_class ⇒ Object (readonly)
Returns the value of attribute slave_model_class.
10 11 12 |
# File 'lib/model_sync.rb', line 10 def slave_model_class @slave_model_class end |
#slave_model_name ⇒ Object (readonly)
Returns the value of attribute slave_model_name.
10 11 12 |
# File 'lib/model_sync.rb', line 10 def slave_model_name @slave_model_name end |
Instance Method Details
#model_sync(options) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/model_sync.rb', line 12 def model_sync() @slave_model_name = [:sync_to].to_s.downcase @slave_model_class = Kernel.const_get(@slave_model_name.classify) @relationship = [:relationship] @mappings = [:mappings] @mapping_block = [:mapping_block] # Add a callback to sync_changes on every save self.after_save :sync_changes self.after_destroy :destroy_slave end |