Module: Ytrbium::DSL
- Defined in:
- lib/ytrbium/dsl.rb
Instance Method Summary collapse
- #call(options = {}) ⇒ Object
- #engine(input = nil, options = {}) ⇒ Object
- #expand(binding = nil) ⇒ Object
- #expand_path(name) ⇒ Object
- #file_resolver ⇒ Object
- #import(name, as: nil, **options) ⇒ Object
Instance Method Details
#call(options = {}) ⇒ Object
16 17 18 |
# File 'lib/ytrbium/dsl.rb', line 16 def call( = {}) YAML.safe_load (binding) end |
#engine(input = nil, options = {}) ⇒ Object
7 8 9 10 |
# File 'lib/ytrbium/dsl.rb', line 7 def engine(input = nil, = {}) @engine = nil if input @engine ||= Engine.new(input, ) end |
#expand(binding = nil) ⇒ Object
12 13 14 |
# File 'lib/ytrbium/dsl.rb', line 12 def (binding = nil) engine.(binding) end |
#expand_path(name) ⇒ Object
20 21 22 |
# File 'lib/ytrbium/dsl.rb', line 20 def (name) file_resolver. name end |
#file_resolver ⇒ Object
3 4 5 |
# File 'lib/ytrbium/dsl.rb', line 3 def file_resolver @file_resolver ||= FileResolver.new end |
#import(name, as: nil, **options) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ytrbium/dsl.rb', line 24 def import(name, as: nil, **) mod = Ytrbium.dsl file_resolver.load(name) do |io, filename| mod.engine(io.read, filename: filename, module: mod) end if as define_method(as) { mod } else mod.call( || {}) end end |