Class: Loom::Pattern::ReferenceSet::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/loom/pattern/reference_set.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(shell_module, source_file) ⇒ Builder

Returns a new instance of Builder.



82
83
84
85
# File 'lib/loom/pattern/reference_set.rb', line 82

def initialize(shell_module, source_file)
  @shell_module = shell_module
  @source_file = source_file
end

Class Method Details

.create(ruby_code, source_file) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/loom/pattern/reference_set.rb', line 65

def create(ruby_code, source_file)
  # Creates an anonymous parent module in which to evaluate the .loom
  # file src. This module acts as a global context for the .loom file.
  # TODO: How should this be hardened?
  shell_module = Module.new
  shell_module.include Loom::Pattern
  # TODO: I think this is my black magic for capturing stacktrace
  # info... I forget the details. Add documentation.
  # TODO: This is where I would need to hack into to auto-include
  # Loom::Pattern in .loom file modules
  shell_module.module_eval ruby_code, source_file, 1
  shell_module.namespace ""

  self.new shell_module, source_file
end

Instance Method Details

#buildObject



87
88
89
90
91
92
93
94
95
# File 'lib/loom/pattern/reference_set.rb', line 87

def build
  ref_set = ReferenceSet.new

  dsl_specs = create_dsl_specs
  pattern_refs = create_pattern_refs dsl_specs, ref_set

  ref_set.add_pattern_refs pattern_refs
  ref_set
end