Class: PackAPI::Mapping::ModelToAPIAttributesTransformer
- Inherits:
-
AbstractTransformer
- Object
- AbstractTransformer
- PackAPI::Mapping::ModelToAPIAttributesTransformer
- Defined in:
- lib/pack_api/mapping/model_to_api_attributes_transformer.rb
Overview
Specialized attribute transformer converting an ActiveRecord model attributes to the attribute names needed to create a ValueObject in the public API.
Instance Attribute Summary
Attributes inherited from AbstractTransformer
#api_type, #data_source, #mappings, #model_type, #options
Instance Method Summary collapse
Methods inherited from AbstractTransformer
Constructor Details
This class inherits a constructor from PackAPI::Mapping::AbstractTransformer
Instance Method Details
#execute ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/pack_api/mapping/model_to_api_attributes_transformer.rb', line 15 def execute api_attribute_names.each_with_object({}) do |api_attribute, result| model_attribute = model_attribute(api_attribute) next unless include_model_attribute?(model_attribute) api_value = transform_value(api_attribute, model_value(model_attribute)) if include_api_attribute?(api_attribute) result[api_attribute] = api_value end end |
#options=(options) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/pack_api/mapping/model_to_api_attributes_transformer.rb', line 8 def () super @optional_attributes_to_include = nil @model_attributes_of_interest = nil @api_attributes_of_interest = nil end |