Module: LowType
- Defined in:
- lib/low_type.rb,
lib/syntax/syntax.rb
Overview
Architecture: ┌────────┐ ┌─────────┐ ┌─────────────┐ ┌─────────┐ ┌─────────┐ │ Lowkey │ │ Proxies │ │ Expressions │ │ LowType │ │ Methods │ └────┬───┘ └────┬────┘ └──────┬──────┘ └────┬────┘ └────┬────┘ │ │ │ │ │ │ Parses AST │ │ │ │ ├─────────────►│ │ │ │ │ │ │ │ │ │ │ Stores │ │ │ │ ├────────────────►│ │ │ │ │ │ │ │ │ │ │ Evaluates │ │ │ │ │◄────────────────┤ │ │ │ │ │ │ │ │ │ │ Redefines │ │ │ │ ├──────────────►│ │ │ │ │ │ │ │ │ Validates │ │ │ │ │◄┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┤ │ │ │ │ │
Defined Under Namespace
Modules: Syntax Classes: Config
Class Method Summary collapse
- .config ⇒ Object
- .configure {|config| ... } ⇒ Object
-
.included(klass) ⇒ Object
Defers evaluation and redefinition until after the class body finishes loading via TracePoint :end.
Class Method Details
.config ⇒ Object
76 77 78 |
# File 'lib/low_type.rb', line 76 def config @config ||= Config.new(true, :error, :type, 100, true, true) end |
.configure {|config| ... } ⇒ Object
80 81 82 |
# File 'lib/low_type.rb', line 80 def configure yield(config) end |
.included(klass) ⇒ Object
Defers evaluation and redefinition until after the class body finishes loading via TracePoint :end.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/low_type.rb', line 35 def self.included(klass) file_path = Low::FileQuery.file_path(klass:) file_proxy = Lowkey.load(file_path) class_proxy = file_proxy[klass.name] klass.include Low::ExpressionHelpers klass.extend Low::ExpressionHelpers klass.extend Low::TypeAccessors klass.extend Low::Types # Use TracePoint :end to capture the class binding after the class body finishes loading. # At :end time, trace.self is the including class and trace.binding is the class body's binding, # stored on class_proxy.class_binding for use by LowType and other consumers. tp = TracePoint.new(:end) do |trace| next unless trace.self == klass class_proxy.class_binding = trace.binding Low::Evaluator.evaluate(method_proxies: class_proxy.keyed_methods, class_binding: class_proxy.class_binding) klass.prepend Low::Redefiner.redefine(method_proxies: class_proxy.instance_methods, class_proxy:) klass.singleton_class.prepend Low::Redefiner.redefine(method_proxies: class_proxy.class_methods, class_proxy:) Low::Adapter::Loader.load(klass:, class_proxy:) tp.disable end tp.enable end |