Class: Moysklad::Universe

Inherits:
Object
  • Object
show all
Defined in:
lib/moysklad/universe.rb

Constant Summary collapse

@@resources_list =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client: nil) ⇒ Universe

Returns a new instance of Universe.

Parameters:



7
8
9
10
11
# File 'lib/moysklad/universe.rb', line 7

def initialize client: nil
  raise "Должен быть client[Moysklad::Client]" unless client.is_a? Moysklad::Client
  @client = client
  @resources={}
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



4
5
6
# File 'lib/moysklad/universe.rb', line 4

def client
  @client
end

Class Method Details

.build(login: nil, password: nil, logger: nil) ⇒ Object

Ленивое создание universe

Parameters:

  • login (defaults to: nil)
  • password (defaults to: nil)


30
31
32
# File 'lib/moysklad/universe.rb', line 30

def self.build login: nil, password: nil, logger: nil
  new client: client_class.new(login: , password: password, logger: nil)
end

.client_classObject



13
14
15
# File 'lib/moysklad/universe.rb', line 13

def self.client_class
  Client
end

Instance Method Details

#all_custom_entitiesObject

Все элементы всех словарей



22
23
24
# File 'lib/moysklad/universe.rb', line 22

def all_custom_entities
  @all_custom_entities ||= .customEntities.map { |d| d.entities(self) }.flatten
end

#class_by_resource(resource) ⇒ Object



42
43
44
# File 'lib/moysklad/universe.rb', line 42

def class_by_resource resource
  "Moysklad::Resources::#{resource.to_s.singularize.capitalize}".constantize
end

#company_settings_metadataObject



17
18
19
# File 'lib/moysklad/universe.rb', line 17

def 
  @company_settings_metadata ||= Moysklad::Entities::CompanySettingsMetadata.build client.get('context/companysettings/metadata'), self
end