Class: MaquinaStream::Components::Library

Inherits:
Object
  • Object
show all
Defined in:
lib/maquina_stream/components.rb

Overview

Probes an installed maquina_components for the destination partial. A plain object rather than a stub: tests inject their own.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view_root) ⇒ Library

Returns a new instance of Library.



42
43
44
# File 'lib/maquina_stream/components.rb', line 42

def initialize(view_root)
  @view_root = Pathname(view_root)
end

Class Method Details

.detect ⇒ Object

Returns nil when the gem is absent, which is the whole point of the optional dependency: absence is a value, not an error.



36
37
38
39
40
# File 'lib/maquina_stream/components.rb', line 36

def self.detect
  return nil unless defined?(::MaquinaComponents::Engine)

  new(::MaquinaComponents::Engine.root.join("app", "views"))
end

Instance Method Details

#defines?(name) ⇒ Boolean

True when the gem itself ships the destination partial. We probe the exact path we would render, never a path we merely hope exists.

Returns:

  • (Boolean)


48
49
50
# File 'lib/maquina_stream/components.rb', line 48

def defines?(name)
  defined_names.include?(name.to_sym)
end