Sha256: ee77eb69f9cfe1f7003711fe66fc522ff31312d95a1ae175fcdc600eeb752402

Contents?: true

Size: 846 Bytes

Versions: 1

Compression:

Stored size: 846 Bytes

Contents

# frozen_string_literal: true

module UnrealReaper
  class Installer
    attr_reader :cls

    def initialize(cls)
      @cls = cls
    end

    def install(package_name, opts = {})
      package = UnrealReaper.packages[package_name.to_sym]
      raise "Not found package '#{package_name}'" unless package
      opts = opts.symbolize_keys

      init_entry
      cls.ur._install(package_name, *package.values_at(:top_cls, :helper_cls, :writer_cls), opts)
    end

    def init_entry
      return if cls.methods.include?(:ur)
      cls.class_eval do
        def self.ur
          @ur_manager ||= Manager.new(self)
        end

        def ur
          @ur_manager ||= begin
            self.class.ur._instance_manager_cls.new(self)
          end
        end

        def ur=(data)
          ur._write(data)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
unreal_reaper-0.1.0 lib/unreal_reaper/installer.rb