Module: ParamsReady::Query::Relation::PageAccessors

Included in:
Parameter::State, ParamsReady::Query::Relation
Defined in:
lib/params_ready/query/relation.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(mod) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/params_ready/query/relation.rb', line 22

def self.extended(mod)
  mod.page_accessor :current
  mod.page_accessor :first
  mod.page_accessor :last
  mod.page_accessor :previous
  mod.page_accessor :next
  mod.page_accessor :before
  mod.page_accessor :after
  mod.page_accessor :limit_at, :limited_at
  mod.page_accessor :toggle, :toggled_order
  mod.page_accessor :reorder, :reordered
end

Instance Method Details

#page_accessor(name, delegate = nil) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/params_ready/query/relation.rb', line 13

def page_accessor(name, delegate = nil)
  delegate ||= "#{name}_page"

  define_method name do |*args|
    send(delegate, *args)&.for_frontend
  end
  ruby2_keywords name
end