Sha256: 8b5aab99935b45879cf59faac39caf4fed659466e73679d1042c873b5df37557

Contents?: true

Size: 1.46 KB

Versions: 33

Compression:

Stored size: 1.46 KB

Contents

# frozen_string_literal  = true

require 'pathname'

class Ree::Container
  class << self
    SEMAPHORE = Mutex.new
    private_constant :SEMAPHORE

    # singleton
    def instance
      SEMAPHORE.synchronize do
        @instance ||= begin
          self.new
        end
      end

      @instance
    end
  end

  include Ree::Args

  MOUNT_AS = [:fn, :object]

  attr_reader :packages_facade

  def initialize
    @packages_facade = Ree::PackagesFacade.new
    @object_compiler = Ree::ObjectCompiler.new(@packages_facade)
  end

  # @param [Ree::Package] package
  # @param [Symbol] object_name
  def compile(package, object_name)
    compile_object("#{package.name}/#{object_name}")
  end

  # @param [String] name_with_package
  # @return [Ree::Object]
  def compile_object(name_with_package)
    check_arg(name_with_package, :name_with_package, String)

    list = name_with_package.to_s.split('/')

    name = nil
    package_name = nil

    if list.size == 2
      package_name = list.first.to_sym
      name = list.last.to_sym
    else
      raise Ree::Error.new("'package/name' definition should be used to load object", :invalid_dsl_usage)
    end

    @packages_facade.get_loaded_package(package_name)
    @packages_facade.load_package_object(package_name, name)
    
    @object_compiler.call(package_name, name)
  end

  # @param [Symbol] package_name
  # @return [Ree::Package]
  def load_package(package_name)
    @packages_facade.load_entire_package(package_name)
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
ree-1.0.32 lib/ree/container.rb
ree-1.0.31 lib/ree/container.rb
ree-1.0.30 lib/ree/container.rb
ree-1.0.29 lib/ree/container.rb
ree-1.0.28 lib/ree/container.rb
ree-1.0.27 lib/ree/container.rb
ree-1.0.26 lib/ree/container.rb
ree-1.0.25 lib/ree/container.rb
ree-1.0.24 lib/ree/container.rb
ree-1.0.23 lib/ree/container.rb
ree-1.0.22 lib/ree/container.rb
ree-1.0.21 lib/ree/container.rb
ree-1.0.20 lib/ree/container.rb
ree-1.0.19 lib/ree/container.rb
ree-1.0.18 lib/ree/container.rb
ree-1.0.17 lib/ree/container.rb
ree-1.0.16 lib/ree/container.rb
ree-1.0.15 lib/ree/container.rb
ree-1.0.14 lib/ree/container.rb
ree-1.0.13 lib/ree/container.rb