Class: JSONAPI::Resources::OptionalPaginators::OptionalPaginator

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/jsonapi/resources/optional_paginators/optional_paginator.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ OptionalPaginator

Returns a new instance of OptionalPaginator.



25
26
27
28
# File 'lib/jsonapi/resources/optional_paginators/optional_paginator.rb', line 25

def initialize(params)
  inner_paginator = paginator_for_params(params).new(params)
  super(inner_paginator)
end

Class Attribute Details

.wrapped_classObject

Returns the value of attribute wrapped_class.



10
11
12
# File 'lib/jsonapi/resources/optional_paginators/optional_paginator.rb', line 10

def wrapped_class
  @wrapped_class
end

Instance Attribute Details

#delegateObject (readonly)

Returns the value of attribute delegate.



19
20
21
# File 'lib/jsonapi/resources/optional_paginators/optional_paginator.rb', line 19

def delegate
  @delegate
end

Class Method Details

.for(paginator_class_argument) ⇒ Object



12
13
14
15
16
# File 'lib/jsonapi/resources/optional_paginators/optional_paginator.rb', line 12

def for(paginator_class_argument)
  Class.new(self).tap do |wrapper_class|
    wrapper_class.wrapped_class = paginator_class_argument
  end
end

.requires_record_countObject



21
22
23
# File 'lib/jsonapi/resources/optional_paginators/optional_paginator.rb', line 21

def self.requires_record_count
  wrapped_class.requires_record_count
end

Instance Method Details

#paginator_for_params(params) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/jsonapi/resources/optional_paginators/optional_paginator.rb', line 30

def paginator_for_params(params)
  if params.nil?
    NullPaginator
  else
    self.class.wrapped_class
  end
end