Class: ROM::Plugins::Resolver Private

Inherits:
Object
  • Object
show all
Defined in:
lib/rom/plugins.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

TODO: move to rom/compat

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(container, type:, adapter: nil) ⇒ Resolver

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Resolver.



53
54
55
56
57
# File 'lib/rom/plugins.rb', line 53

def initialize(container, type:, adapter: nil)
  @container = container
  @type = type
  @_adapter = adapter
end

Instance Attribute Details

#_adapterObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



50
51
52
# File 'lib/rom/plugins.rb', line 50

def _adapter
  @_adapter
end

#containerObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



50
51
52
# File 'lib/rom/plugins.rb', line 50

def container
  @container
end

#typeObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



50
51
52
# File 'lib/rom/plugins.rb', line 50

def type
  @type
end

Instance Method Details

#adapter(name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



60
61
62
# File 'lib/rom/plugins.rb', line 60

def adapter(name)
  self.class.new(container, type: type, adapter: name)
end

#fetch(name, adapter = nil) ⇒ Object Also known as: []

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/rom/plugins.rb', line 65

def fetch(name, adapter = nil)
  if adapter
    key = [adapter, type, name].compact.join(".")

    if container.key?(key)
      container.resolve(key)
    else
      fetch(name)
    end
  elsif _adapter && key?(name)
    fetch(name, _adapter)
  else
    key = "#{type}.#{name}"
    container.resolve(key)
  end
end

#key?(name) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


84
85
86
# File 'lib/rom/plugins.rb', line 84

def key?(name)
  container.key?([_adapter, type, name].compact.join("."))
end