Sha256: 5d314d227a832c8ac00230c98888282605f49ad43eb6f297b1e2376d8cb68308
Contents?: true
Size: 776 Bytes
Versions: 16
Compression:
Stored size: 776 Bytes
Contents
module Moysklad::Entities class RowItems < Virtus::Attribute include ActiveSupport::Inflector def coerce(items) items.map do |item| type = item['meta']['type'] entity_class = find_entity_class type entity_class.new item end end private def find_entity_class(type) case type when 'customentity' Moysklad::Entities::CustomEntity else class_name = 'Moysklad::Entities::' + camelize(type) raise Moysklad::Error, "No entity class for #{type} type" unless Object.const_defined? class_name constantize class_name end end end class Collection < Base attribute :context, Context attribute :meta, CollectionMeta attribute :rows, RowItems end end
Version data entries
16 entries across 16 versions & 1 rubygems