Class: JSONAPI::Resources::OptionalPaginators::OptionalPaginator
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- JSONAPI::Resources::OptionalPaginators::OptionalPaginator
- Defined in:
- lib/jsonapi/resources/optional_paginators/optional_paginator.rb
Class Attribute Summary collapse
-
.wrapped_class ⇒ Object
Returns the value of attribute wrapped_class.
Instance Attribute Summary collapse
-
#delegate ⇒ Object
readonly
Returns the value of attribute delegate.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params) ⇒ OptionalPaginator
constructor
A new instance of OptionalPaginator.
- #paginator_for_params(params) ⇒ Object
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_class ⇒ Object
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
#delegate ⇒ Object (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_count ⇒ Object
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 |