Class: BetterSJR::TryCatchStatement
- Inherits:
-
Object
- Object
- BetterSJR::TryCatchStatement
- Defined in:
- lib/better_sjr/try_catch_statement.rb
Overview
Wraps a given code snippet in a JavaScript try-catch statement
Instance Attribute Summary collapse
-
#original_code ⇒ String
The code without a try-catch statement surrounding it.
Instance Method Summary collapse
-
#initialize(code) ⇒ TryCatchStatement
constructor
Returns a new instance of TryCatchStatement.
-
#wrapped_code ⇒ String
Wraps the original code in a try-catch statement.
Constructor Details
#initialize(code) ⇒ TryCatchStatement
Returns a new instance of TryCatchStatement
10 11 12 |
# File 'lib/better_sjr/try_catch_statement.rb', line 10 def initialize(code) @original_code = code end |
Instance Attribute Details
#original_code ⇒ String
Returns the code without a try-catch statement surrounding it.
5 6 7 |
# File 'lib/better_sjr/try_catch_statement.rb', line 5 def original_code @original_code end |
Instance Method Details
#wrapped_code ⇒ String
Wraps the original code in a try-catch statement
17 18 19 20 21 22 23 24 25 |
# File 'lib/better_sjr/try_catch_statement.rb', line 17 def wrapped_code <<-TRYCATCH try { #{original_code} } catch(e) { console.error("Rails SJR error", e); } TRYCATCH end |