module Moysklad::Entities
  class AttributeValue < Virtus::Attribute
    def coerce(value)
      if value.is_a? String
        value
      elsif value.is_a? ::Hash
        if value['meta']['type'] == 'customentity'
          CustomEntity.new value
        else
          raise "Unknown meta type: #{value['meta']['type']}"
        end
      else
        raise "Unknown value type (#{value}) #{value.class}"
      end
    end
  end
end

module Moysklad::Entities
  class AttributeValue < Virtus::Attribute
    def coerce(value)
      case value
      when String, Float
        value
      when Hash
        if value['meta']['type'] == 'customentity'
          CustomEntity.new value
        else
          raise "Unknown meta type: #{value['meta']['type']}"
        end
      else
        raise "Unknown value type (#{value}) #{value.class}"
      end
    end
  end
end

Add float to attribute value
Add float to attribute value
