Module: RenderTurboStream::ViewHelpers

Defined in:
lib/render_turbo_stream/view_helpers.rb

Instance Method Summary collapse

Instance Method Details

#last_saved_objectObject



19
20
21
# File 'lib/render_turbo_stream/view_helpers.rb', line 19

def last_saved_object
  GlobalID::Locator.locate(session[:last_saved_object])
end

#target_id(id = nil) ⇒ Object



12
13
14
15
16
17
# File 'lib/render_turbo_stream/view_helpers.rb', line 12

def target_id(id = nil)
  libs = RenderTurboStream::Libs
  virt_path = self.instance_variable_get('@current_template').instance_variable_get('@virtual_path')
  obj = (id ? id : eval("@#{controller_name.singularize}"))
  libs.target_id(virt_path, obj)
end

#turbo_target_tag(id = nil, &block) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/render_turbo_stream/view_helpers.rb', line 4

def turbo_target_tag(id = nil, &block)
   :'turbo-target', id: target_id(id) do
    if block_given?
      capture(&block)
    end
  end
end