Sha256: 74fcbf3cdc7b45958fd2e23386435304ea215d968dde90cddda06aed5a6e9680

Contents?: true

Size: 684 Bytes

Versions: 6

Compression:

Stored size: 684 Bytes

Contents

# frozen_string_literal: true

require 'eac_fs/contexts'
require 'eac_fs/patches/module/fs_cache'

class Object
  ::EacFs::Contexts::TYPES.each do |type|
    class_eval <<~CODE, __FILE__, __LINE__ + 1
      # @return [EacFs::StorageTree]
      def fs_#{type}
        oid = fs_object_id_by_type(:'#{type}')
        oid = [oid.to_s] unless oid.is_a?(::Enumerable)
        oid.inject(self.class.fs_#{type}) { |a, e| a.child(e.to_s) }
      end
    CODE
  end

  # @return [String, Array<String>]
  def fs_object_id
    raise 'Abstract method hit'
  end

  def fs_object_id_by_type(type)
    method = "fs_#{type}_object_id"
    respond_to?(method) ? send(method) : fs_object_id
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
avm-tools-0.114.2 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
avm-tools-0.114.1 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_fs-0.11.1 lib/eac_fs/patches/object/fs_cache.rb
eac_fs-0.11.0 lib/eac_fs/patches/object/fs_cache.rb
avm-tools-0.114.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_fs-0.10.0 lib/eac_fs/patches/object/fs_cache.rb