Class: Wallaby::ActiveRecord::ModelDecorator::FieldsBuilder::StiBuilder
- Inherits:
-
Object
- Object
- Wallaby::ActiveRecord::ModelDecorator::FieldsBuilder::StiBuilder
- Defined in:
- lib/adapters/wallaby/active_record/model_decorator/fields_builder/sti_builder.rb
Overview
This class updates the field metadata’s value of type and sti_class_list for STI (Single Table Inheritance) model
Instance Method Summary collapse
-
#initialize(model_class) ⇒ StiBuilder
constructor
A new instance of StiBuilder.
-
#update(metadata, column) ⇒ Object
Update the field metadata’s value for type and sti_class_list.
Constructor Details
#initialize(model_class) ⇒ StiBuilder
Returns a new instance of StiBuilder.
11 12 13 |
# File 'lib/adapters/wallaby/active_record/model_decorator/fields_builder/sti_builder.rb', line 11 def initialize(model_class) @model_class = model_class end |
Instance Method Details
#update(metadata, column) ⇒ Object
Update the field metadata’s value for type and sti_class_list
18 19 20 21 22 23 |
# File 'lib/adapters/wallaby/active_record/model_decorator/fields_builder/sti_builder.rb', line 18 def update(, column) return unless @model_class.inheritance_column == column.name [:type] = 'sti' [:sti_class_list] = sti_list(find_sti_parent_of(@model_class)) end |