Class: MaquinaStream::Components::Library
- Inherits:
-
Object
- Object
- MaquinaStream::Components::Library
- 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
-
.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.
Instance Method Summary collapse
-
#defines?(name) ⇒ Boolean
True when the gem itself ships the destination partial.
-
#initialize(view_root) ⇒ Library
constructor
A new instance of Library.
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.
48 49 50 |
# File 'lib/maquina_stream/components.rb', line 48 def defines?(name) defined_names.include?(name.to_sym) end |