Class: Opal::Rewriter
- Inherits:
-
Object
- Object
- Opal::Rewriter
- Defined in:
- opal/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.
70 71 72 |
# File 'opal/lib/opal/rewriter.rb', line 70 def initialize(sexp) @sexp = sexp end |
Class Method Details
.delete(rewriter) ⇒ Object
32 33 34 |
# File 'opal/lib/opal/rewriter.rb', line 32 def delete(rewriter) list.delete(rewriter) end |
.disable(except: nil) ⇒ Object
36 37 38 39 40 41 42 |
# File 'opal/lib/opal/rewriter.rb', line 36 def disable(except: nil) old_disabled = @disabled @disabled = except || true yield ensure @disabled = old_disabled end |
.disabled? ⇒ Boolean
44 45 46 |
# File 'opal/lib/opal/rewriter.rb', line 44 def disabled? @disabled == true end |
.list ⇒ Object
24 25 26 |
# File 'opal/lib/opal/rewriter.rb', line 24 def list @list ||= [] end |
.rewritter_disabled?(rewriter) ⇒ Boolean
48 49 50 51 |
# File 'opal/lib/opal/rewriter.rb', line 48 def rewritter_disabled?(rewriter) return false if @disabled == false @disabled != rewriter end |
.use(rewriter) ⇒ Object
28 29 30 |
# File 'opal/lib/opal/rewriter.rb', line 28 def use(rewriter) list << rewriter end |
Instance Method Details
#process ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 |
# File 'opal/lib/opal/rewriter.rb', line 74 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 |