Sha256: 6efc8df4bff564d0c1928dbd300ad24f35442313de9ddcd0089c72b35c0c1eac
Contents?: true
Size: 1.44 KB
Versions: 1
Compression:
Stored size: 1.44 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 @company_settings_metadata ||= Moysklad::Entities::CompanySettingsMetadata.build client.get('context/companysettings/metadata'), self end # Все элементы всех словарей def all_custom_entities @all_custom_entities ||= company_settings_metadata.customEntities.map { |d| d.entities(self) }.flatten end # Ленивое создание universe # # @param login # @param password def self.build login: nil, password: nil, logger: nil, proxy: nil new client: client_class.new(login: login, password: password, logger: nil, proxy: proxy) 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
moysklad-0.5 | lib/moysklad/universe.rb |