Class: ForestLiana::SchemaAdapter
- Inherits:
-
Object
- Object
- ForestLiana::SchemaAdapter
- Defined in:
- app/services/forest_liana/schema_adapter.rb
Instance Method Summary collapse
-
#initialize(model) ⇒ SchemaAdapter
constructor
A new instance of SchemaAdapter.
- #perform ⇒ Object
Constructor Details
#initialize(model) ⇒ SchemaAdapter
Returns a new instance of SchemaAdapter.
3 4 5 |
# File 'app/services/forest_liana/schema_adapter.rb', line 3 def initialize(model) @model = model end |
Instance Method Details
#perform ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/services/forest_liana/schema_adapter.rb', line 7 def perform add_columns add_associations # ActsAsTaggable attribute if @model.respond_to?(:acts_as_taggable) && @model.acts_as_taggable.try(:to_a) @model.acts_as_taggable.to_a.each do |key, value| field = collection.fields.find {|x| x[:field] == key.to_s} if field field[:type] = 'String' field[:reference] = nil field[:inverse_of] = nil collection.fields.delete_if do |f| ['taggings', 'base_tags', 'tag_taggings'].include?(f[:field]) end end end end collection end |