Class: Babl::Operators::Partial::AbsoluteLookupContext
- Inherits:
-
Object
- Object
- Babl::Operators::Partial::AbsoluteLookupContext
- Defined in:
- lib/babl/operators/partial.rb
Instance Attribute Summary collapse
-
#search_path ⇒ Object
readonly
Returns the value of attribute search_path.
Instance Method Summary collapse
- #find(partial_name) ⇒ Object
-
#initialize(search_path) ⇒ AbsoluteLookupContext
constructor
A new instance of AbsoluteLookupContext.
Constructor Details
#initialize(search_path) ⇒ AbsoluteLookupContext
Returns a new instance of AbsoluteLookupContext.
33 34 35 36 |
# File 'lib/babl/operators/partial.rb', line 33 def initialize(search_path) @search_path = search_path raise Errors::InvalidTemplate, 'Invalid search path' unless search_path end |
Instance Attribute Details
#search_path ⇒ Object (readonly)
Returns the value of attribute search_path.
31 32 33 |
# File 'lib/babl/operators/partial.rb', line 31 def search_path @search_path end |
Instance Method Details
#find(partial_name) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/babl/operators/partial.rb', line 38 def find(partial_name) query = File.join(search_path, "{#{partial_name}}{.babl,}") path = Dir[query].first return unless path source = File.read(path) [path, source, self] end |