Sha256: ad0e0add3a8ba030aff1ffaf5241a04a00325ec8e7d090c5a409531d9f4c7b85

Contents?: true

Size: 786 Bytes

Versions: 130

Compression:

Stored size: 786 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(fs_#{type}_parent) { |a, e| a.child(e.to_s) }
      end

      # @return [EacFs::StorageTree]
      def fs_#{type}_parent
        self.class.fs_#{type}
      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

130 entries across 130 versions & 3 rubygems

Version Path
eac_tools-0.13.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.12.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.11.1 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.11.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.10.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.9.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_fs-0.12.3 lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.8.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.7.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.6.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.5.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.4.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.3.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.2.2 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_fs-0.12.2 lib/eac_fs/patches/object/fs_cache.rb
avm-tools-0.120.2 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
avm-tools-0.120.1 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
avm-tools-0.120.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
avm-tools-0.119.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
avm-tools-0.118.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb