Sha256: 6c64198a1b57007bb00629d892b9aed5802c7ddecb55c116d50853ced9f90db8
Contents?: true
Size: 625 Bytes
Versions: 27
Compression:
Stored size: 625 Bytes
Contents
require 'attr_json/type/polymorphic_model' # Extending the PolymorphicModel to use the Spina::PARTS array as input # as opposed to arguments module AttrJson module Type class SpinaPartsModel < PolymorphicModel def model_names spina_parts_lookup.keys end def model_types spina_parts_lookup.values end def spina_parts_lookup @spina_parts_lookup ||= Spina::PARTS.map(&:to_type).map do |type| [type.model.name, type] end.to_h end def type_for_model_name(model_name) spina_parts_lookup[model_name] end end end end
Version data entries
27 entries across 27 versions & 1 rubygems