Class: Babl::Operators::Partial::AbsoluteLookupContext

Inherits:
Object
  • Object
show all
Defined in:
lib/babl/operators/partial.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_pathObject (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