Class: TurboScroll::Auto

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
Turbo::FramesHelper
Defined in:
lib/turbo-scroll/auto.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page:, loader_dom_id: :turbo_loader, loading_indicator: true) ⇒ Auto

Returns a new instance of Auto.



10
11
12
13
14
# File 'lib/turbo-scroll/auto.rb', line 10

def initialize(page:, loader_dom_id: :turbo_loader, loading_indicator: true)
  @page = page
  @loader_dom_id = loader_dom_id
  @loading_indicator = loading_indicator
end

Instance Attribute Details

#loader_dom_idObject (readonly)

Returns the value of attribute loader_dom_id.



8
9
10
# File 'lib/turbo-scroll/auto.rb', line 8

def loader_dom_id
  @loader_dom_id
end

#loading_indicatorObject (readonly)

Returns the value of attribute loading_indicator.



8
9
10
# File 'lib/turbo-scroll/auto.rb', line 8

def loading_indicator
  @loading_indicator
end

#pageObject (readonly)

Returns the value of attribute page.



8
9
10
# File 'lib/turbo-scroll/auto.rb', line 8

def page
  @page
end

Instance Method Details

#next_page_pathObject



21
22
23
# File 'lib/turbo-scroll/auto.rb', line 21

def next_page_path
  url_for(page: page, **query_params)
end

#next_page_stream_pathObject



25
26
27
# File 'lib/turbo-scroll/auto.rb', line 25

def next_page_stream_path
  url_for(format: :turbo_stream, page: page, **query_params)
end

#query_paramsObject



16
17
18
19
# File 'lib/turbo-scroll/auto.rb', line 16

def query_params
  @query_params ||=
    request.query_parameters.except(:page, :raw, :format)
end

#render?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/turbo-scroll/auto.rb', line 29

def render?
  page
end