Module: Spider::Migrations::PreviousModel::ClassMethods
- Defined in:
- lib/spiderfw/model/migrations/previous_model.rb
Instance Method Summary collapse
- #class_table_inheritance(params = {}) ⇒ Object
- #element(name, type, attributes = {}, &proc) ⇒ Object
- #previous_model_of(model = nil) ⇒ Object
Instance Method Details
#class_table_inheritance(params = {}) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/spiderfw/model/migrations/previous_model.rb', line 37 def class_table_inheritance(params={}) unless params[:name] spm = nil mpm = nil if @replacement_model spm = @replacement_model.parent_module else spm = self.parent_module.parent_module end if superclass.respond_to?(:previous_model_of) if superclass.previous_model_of mpm = superclass.previous_model_of else mpm = superclass.parent_module.parent_module end else mpm = superclass.parent_module end integrated_name = (spm == mpm) ? superclass.short_name : superclass.name integrated_name = Spider::Inflector.underscore(integrated_name).gsub('/', '_') params[:name] = integrated_name end super(params) end |
#element(name, type, attributes = {}, &proc) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/spiderfw/model/migrations/previous_model.rb', line 62 def element(name, type, attributes={}, &proc) super if @elements[name].junction? @elements[name].model.send(:include, PreviousModel) end end |
#previous_model_of(model = nil) ⇒ Object
31 32 33 34 |
# File 'lib/spiderfw/model/migrations/previous_model.rb', line 31 def previous_model_of(model=nil) @replacement_model = model if model @replacement_model end |