Sha256: 562d064ab4733cc64c9d60811eeb3d46c7dfd5962a09e256e3fec6390d1649b7
Contents?: true
Size: 1.42 KB
Versions: 4
Compression:
Stored size: 1.42 KB
Contents
module Moysklad class Universe cattr_reader :resources_list attr_reader :client # @param client[Moysklad::Client] def initialize client: nil raise "Должен быть client[Moysklad::Client]" unless client.is_a? Moysklad::Client @client = client @resources={} end def self.client_class Client end def company_settings_metadata Moysklad::Entities::CompanySettingsMetadata.build client.get('entity/companysettings/metadata'), self end # Все элементы всех словарей def all_custom_entities list = [] dictionaries = company_settings_metadata.customEntities dictionaries.each do |d| list += d.entities(self) end list end # Ленивое создание universe # # @param login # @param password def self.build login: nil, password: nil new client: client_class.new(login: login, password: password) end @@resources_list = [] Moysklad::Resources.resources.each do |resource_klass| @@resources_list << resource_klass.pluralized_type.to_sym define_method resource_klass.pluralized_type do |opts={}| @resources[resource_klass.type] ||= resource_klass.indexed( **opts.merge(client: client) ) end end def class_by_resource resource "Moysklad::Resources::#{resource.to_s.singularize.capitalize}".constantize end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
moysklad-0.3.4 | lib/moysklad/universe.rb |
moysklad-0.3.3 | lib/moysklad/universe.rb |
moysklad-0.3.2 | lib/moysklad/universe.rb |
moysklad-0.3.1 | lib/moysklad/universe.rb |