Class: Moysklad::Universe
- Inherits:
-
Object
- Object
- Moysklad::Universe
- Defined in:
- lib/moysklad/universe.rb
Constant Summary collapse
- @@resources_list =
[]
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Class Method Summary collapse
-
.build(login: nil, password: nil) ⇒ Object
Ленивое создание universe.
- .client_class ⇒ Object
Instance Method Summary collapse
-
#all_custom_entities ⇒ Object
Все элементы всех словарей.
- #class_by_resource(resource) ⇒ Object
- #company_settings_metadata ⇒ Object
-
#initialize(client: nil) ⇒ Universe
constructor
A new instance of Universe.
Constructor Details
#initialize(client: nil) ⇒ Universe
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
#client ⇒ Object (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) ⇒ Object
Ленивое создание universe
35 36 37 |
# File 'lib/moysklad/universe.rb', line 35 def self.build login: nil, password: nil new client: client_class.new(login: login, password: password) end |
.client_class ⇒ Object
13 14 15 |
# File 'lib/moysklad/universe.rb', line 13 def self.client_class Client end |
Instance Method Details
#all_custom_entities ⇒ Object
Все элементы всех словарей
22 23 24 25 26 27 28 29 |
# File 'lib/moysklad/universe.rb', line 22 def all_custom_entities list = [] dictionaries = .customEntities dictionaries.each do |d| list += d.entities(self) end list end |
#class_by_resource(resource) ⇒ Object
47 48 49 |
# File 'lib/moysklad/universe.rb', line 47 def class_by_resource resource "Moysklad::Resources::#{resource.to_s.singularize.capitalize}".constantize end |
#company_settings_metadata ⇒ Object
17 18 19 |
# File 'lib/moysklad/universe.rb', line 17 def Moysklad::Entities::CompanySettingsMetadata.build client.get('entity/companysettings/metadata'), self end |