Sha256: ef520b3274bdd9c324f80c6825ee1289ca412dfa352be42f77d9e98f1cd90589

Contents?: true

Size: 472 Bytes

Versions: 165

Compression:

Stored size: 472 Bytes

Contents

# frozen_string_literal: true

module EacRubyUtils
  # Provides the method context which search and call a method in self and ancestor objects.
  module Contextualizable
    def context(method)
      current = self
      while current
        return current.send(method) if current.respond_to?(method)

        current = current.respond_to?(:parent) ? current.parent : nil
      end
      raise "Context method \"#{method}\" not found for #{self.class}"
    end
  end
end

Version data entries

165 entries across 165 versions & 3 rubygems

Version Path
ehbrs-tools-0.21.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/contextualizable.rb
avm-tools-0.99.1 vendor/eac_ruby_utils/lib/eac_ruby_utils/contextualizable.rb
eac_ruby_utils-0.64.0 lib/eac_ruby_utils/contextualizable.rb
avm-tools-0.99.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/contextualizable.rb
avm-tools-0.98.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/contextualizable.rb
avm-tools-0.97.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/contextualizable.rb
avm-tools-0.96.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/contextualizable.rb
eac_ruby_utils-0.63.0 lib/eac_ruby_utils/contextualizable.rb
avm-tools-0.95.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/contextualizable.rb
eac_ruby_utils-0.62.1 lib/eac_ruby_utils/contextualizable.rb
avm-tools-0.94.3 vendor/eac_ruby_utils/lib/eac_ruby_utils/contextualizable.rb
eac_ruby_utils-0.62.0 lib/eac_ruby_utils/contextualizable.rb
eac_ruby_utils-0.61.0 lib/eac_ruby_utils/contextualizable.rb
avm-tools-0.94.2 vendor/eac_ruby_utils/lib/eac_ruby_utils/contextualizable.rb
eac_ruby_utils-0.60.0 lib/eac_ruby_utils/contextualizable.rb
avm-tools-0.94.1 vendor/eac_ruby_utils/lib/eac_ruby_utils/contextualizable.rb
eac_ruby_utils-0.59.0 lib/eac_ruby_utils/contextualizable.rb
ehbrs-tools-0.20.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/contextualizable.rb
avm-tools-0.94.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/contextualizable.rb
avm-tools-0.93.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/contextualizable.rb