lib/moy_sklad/client/resource.rb
# Nested object finder by type uuid + object uuid.
#
# MS data model have arrays which contains objects where each object have a special "type"
# uuid and object uuid. Type + Object uuids are PK for the object.
#
# @attr name [Symbol] attribute name
# @attr type [String] "type" uuid
# @attr key  [String] "object" uuid
#
Nested object finder by type uuid + object uuid.
MS data model have arrays which contains objects where each object have a special "type"
uuid and object uuid. Type + Object uuids are PK for the object.
Nested object finder by type uuid + object uuid . MS data model have arrays which contains objects where each object have a special " type " uuid and object uuid . Type + Object uuids are PK for the object .
def find_object(name, type, key)
      return nil if self.send(name).is_a?(MoySklad::Client::Attribute::MissingAttr)
      create_nested_resource(name)
      self.send("#{name}=", [self.send(name)]) unless self.send(name).is_a?(Array)
      self.send(name).each do |v|
        return v if v.send(type) == key
      end
      nil
    end
def find_object ( name , type , key ) return nil if self . send ( name ) . is_a? ( MoySklad :: Client :: Attribute :: MissingAttr ) create_nested_resource ( name ) self . send ( "#{name}=" , [ self . send ( name ) ] ) unless self . send ( name ) . is_a? ( Array ) self . send ( name ) . each do | v | return v if v . send ( type ) == key end nil end
Nested object finder by type uuid + object uuid.
Nested object finder by type uuid + object uuid .
# Convert single attr to array
name
<not_specific>
type
<not_specific>
key
<not_specific>
attr
None
attr
None
attr
None