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.76.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.75.2 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.75.1 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.75.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.74.1 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.74.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.73.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.72.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.70.1 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.70.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.69.1 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.69.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.68.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.67.1 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.67.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.66.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.65.1 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.65.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.64.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb
eac_tools-0.63.0 sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb