Sha256: 98bca367bbe40a17c90384d6bb6ac2094c262b01c9fccd78fe1bbc7f1c880ea6

Contents?: true

Size: 898 Bytes

Versions: 3

Compression:

Stored size: 898 Bytes

Contents

module Moysklad::Entities
  class Attribute < Base
    include Moysklad::Entities::Common

    tag 'attribute'

    attribute :metadataUuid,    String
    attribute :valueString,     String
    attribute :valueText,       String

    attribute :entityValueUuid, String

    # Объект описывающий тип атритуба
    def metadata universe
      universe.metadata.subresource_by_name(:GoodFolder).find  metadataUuid
    end

    def attributeName universe
      metadata(universe).name
    end

    def get_value universe
      md = metadata universe
      case md.attrType
      when 'ID_CUSTOM'
        universe.custom_entities.find( entityValueUuid ).name
      when 'TEXT'
        valueText
      when 'STRING'
        valueString
      else
        raise "Не известный тип мета-аттрибута #{md.uuid}: #{md.attrType}"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
moysklad-0.1.3 lib/moysklad/entities/attribute.rb
moysklad-0.1.2 lib/moysklad/entities/attribute.rb
moysklad-0.1.1 lib/moysklad/entities/attribute.rb