Class: Slocks::BlocksTemplateHandler
- Inherits:
-
Object
- Object
- Slocks::BlocksTemplateHandler
- Defined in:
- lib/slocks/template_handler.rb
Direct Known Subclasses
Class Method Summary collapse
- .call(template, source = nil) ⇒ Object
- .default_format ⇒ Object
- .handles_encoding? ⇒ Boolean
- .preamble ⇒ Object
- .translate_location(spot, _backtrace_location, _source) ⇒ Object
Class Method Details
.call(template, source = nil) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/slocks/template_handler.rb', line 37 def call(template, source = nil) source ||= template.source " \#{preamble}\n \#{source}\n { blocks: @__slocks_builder.blocks }\n EOS\nend\n" |
.default_format ⇒ Object
26 |
# File 'lib/slocks/template_handler.rb', line 26 def default_format = :slack_message |
.handles_encoding? ⇒ Boolean
56 |
# File 'lib/slocks/template_handler.rb', line 56 def handles_encoding? = true |
.preamble ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/slocks/template_handler.rb', line 28 def preamble = "\n\n@__slocks_builder ||= Slocks::BlocksBuilder.new(self)\ndef method_missing(m, *a, **k, &b)\n @__slocks_builder.respond_to?(m) ? @__slocks_builder.public_send(m, *a, **k, &b) : super\nend\n" |
.translate_location(spot, _backtrace_location, _source) ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/slocks/template_handler.rb', line 46 def translate_location(spot, _backtrace_location, _source) # eat your heart out rails-core # this sucks but seems to work plen = preamble.lines.size + 2 spot[:first_lineno] -= plen spot[:last_lineno] -= plen spot[:script_lines] = spot[:script_lines][plen..-4] spot end |