Class: Opal::Rewriter
- Inherits:
-
Object
- Object
- Opal::Rewriter
- Defined in:
- lib/opal/rewriter.rb
Class Method Summary collapse
- .delete(rewriter) ⇒ Object
- .disable(except: nil) ⇒ Object
- .disabled? ⇒ Boolean
- .list ⇒ Object
- .rewritter_disabled?(rewriter) ⇒ Boolean
- .use(rewriter) ⇒ Object
Instance Method Summary collapse
-
#initialize(sexp) ⇒ Rewriter
constructor
A new instance of Rewriter.
- #process ⇒ Object
Constructor Details
#initialize(sexp) ⇒ Rewriter
Returns a new instance of Rewriter.
76 77 78 |
# File 'lib/opal/rewriter.rb', line 76 def initialize(sexp) @sexp = sexp end |
Class Method Details
.delete(rewriter) ⇒ Object
35 36 37 |
# File 'lib/opal/rewriter.rb', line 35 def delete(rewriter) list.delete(rewriter) end |
.disable(except: nil) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/opal/rewriter.rb', line 39 def disable(except: nil) old_disabled = @disabled @disabled = except || true yield ensure @disabled = old_disabled end |
.disabled? ⇒ Boolean
47 48 49 |
# File 'lib/opal/rewriter.rb', line 47 def disabled? @disabled == true end |
.list ⇒ Object
27 28 29 |
# File 'lib/opal/rewriter.rb', line 27 def list @list ||= [] end |
.rewritter_disabled?(rewriter) ⇒ Boolean
51 52 53 54 |
# File 'lib/opal/rewriter.rb', line 51 def rewritter_disabled?(rewriter) return false if @disabled == false @disabled != rewriter end |
.use(rewriter) ⇒ Object
31 32 33 |
# File 'lib/opal/rewriter.rb', line 31 def use(rewriter) list << rewriter end |
Instance Method Details
#process ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/opal/rewriter.rb', line 80 def process return @sexp if self.class.disabled? self.class.list.each do |rewriter_class| next if self.class.rewritter_disabled?(rewriter_class) rewriter = rewriter_class.new @sexp = rewriter.process(@sexp) end @sexp end |