Class: TurboScroll::More

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page:, loader_dom_id: :turbo_loader) ⇒ More

Returns a new instance of More.



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

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

Instance Attribute Details

#loader_dom_idObject (readonly)

Returns the value of attribute loader_dom_id.



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

def loader_dom_id
  @loader_dom_id
end

#pageObject (readonly)

Returns the value of attribute page.



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

def page
  @page
end

Instance Method Details

#next_page_pathObject



20
21
22
# File 'lib/turbo-scroll/more.rb', line 20

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

#next_page_stream_pathObject



24
25
26
# File 'lib/turbo-scroll/more.rb', line 24

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

#query_paramsObject



15
16
17
18
# File 'lib/turbo-scroll/more.rb', line 15

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

#render?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/turbo-scroll/more.rb', line 28

def render?
  page
end