Sha256: 4bc4a853c97f83dc0a3f98ff03a866679e29e374b10e88e8007730ace61e2bf7
Contents?: true
Size: 1018 Bytes
Versions: 4
Compression:
Stored size: 1018 Bytes
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 # Ленивое создание 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 @resources[resource_klass.type] ||= resource_klass.indexed( 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.2.1 | lib/moysklad/universe.rb |
moysklad-0.2.0 | lib/moysklad/universe.rb |
moysklad-0.1.5 | lib/moysklad/universe.rb |
moysklad-0.1.4 | lib/moysklad/universe.rb |