Class: ProductLine::SpecificationsMasher
- Inherits:
-
BaseService
- Object
- BaseService
- ProductLine::SpecificationsMasher
- Defined in:
- app/services/product_line/specifications_masher.rb
Defined Under Namespace
Classes: Result
Instance Method Summary collapse
-
#process(product_line, options = {}) ⇒ Object
Add raw_array: true if you want raw to always return as an array.
Methods inherited from BaseService
#initialize, #log_debug, #log_error, #log_info, #log_warning, #logger, #options, #tagged_logger
Constructor Details
This class inherits a constructor from BaseService
Instance Method Details
#process(product_line, options = {}) ⇒ Object
Add raw_array: true if you want raw to always return as an array
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/services/product_line/specifications_masher.rb', line 8 def process(product_line, ={}) specifications = {} product_specifications = product_line.self_and_inherited_specifications.where(template: false, method: 'text', propagation: %w(0 2)) product_specifications.each do |ps| token = ps.token.presence || ps.name.parameterize.underscore result = ps.get_specification_data(product_line, skip_validation: true) specifications[token.to_sym] = { id: token.to_s.camelize(:lower), name: ps.name, output: result.formatted, raw: result.raw, units: ps.units.presence, product_specification_id: ps.id, visibility: ps.visibility, grouping: ps.grouping, description: ps.description } end Result.new(specifications: specifications.deep_symbolize_keys) end |