Sha256: 1191a3e3027baae9f11fc235011a042c3b71acf0df6b218f61b72d67742f888b

Contents?: true

Size: 708 Bytes

Versions: 1

Compression:

Stored size: 708 Bytes

Contents

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

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

    Moysklad::Resources.resources.each do |resource_klass|
      define_method resource_klass.pluralized_type do
        @resources[resource_klass.type] ||= Moysklad::Resources::Indexed.new resource_klass.new( client: client )
      end
    end

    private

    attr_reader :client
    
    def available_resources
      [:features, :consignments]
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
moysklad-0.0.2 lib/moysklad/universe.rb