Class: PropsBuilder
- Inherits:
-
Object
- Object
- PropsBuilder
- Extended by:
- T::Sig
- Defined in:
- lib/activerecord-ejection_seat/props_builder.rb
Overview
Creates initialization payload for targeted T::Struct
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(model:, target_struct:) ⇒ PropsBuilder
constructor
A new instance of PropsBuilder.
Constructor Details
#initialize(model:, target_struct:) ⇒ PropsBuilder
Returns a new instance of PropsBuilder.
14 15 16 17 |
# File 'lib/activerecord-ejection_seat/props_builder.rb', line 14 def initialize(model:, target_struct:) @model = model @target_struct = target_struct end |
Instance Method Details
#build ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/activerecord-ejection_seat/props_builder.rb', line 20 def build target_struct.props.keys.each_with_object({}) do |prop_name, returned_props| attribute = model.respond_to?(prop_name) ? build_attribute(prop_name) : nil returned_props[prop_name] = attribute end end |