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.62.1 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.62.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.61.1 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.61.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.60.3 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.60.2 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.60.1 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.60.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.59.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.58.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.57.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.56.1 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.56.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.55.7 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.55.6 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.55.5 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.55.4 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.55.3 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.55.2 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.55.1 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb