Class: ParamsReady::Pagination::KeysetPaginationDefinition
- Inherits:
-
ParamsReady::Parameter::StructParameterDefinition
- Object
- ParamsReady::Parameter::AbstractDefinition
- ParamsReady::Parameter::Definition
- ParamsReady::Parameter::AbstractStructParameterDefinition
- ParamsReady::Parameter::StructParameterDefinition
- ParamsReady::Pagination::KeysetPaginationDefinition
- Defined in:
- lib/params_ready/pagination/keyset_pagination.rb
Constant Summary collapse
- MIN_LIMIT =
1
Instance Attribute Summary collapse
-
#default_limit ⇒ Object
readonly
Returns the value of attribute default_limit.
Attributes inherited from ParamsReady::Parameter::AbstractStructParameterDefinition
Attributes inherited from ParamsReady::Parameter::Definition
Attributes inherited from ParamsReady::Parameter::AbstractDefinition
Instance Method Summary collapse
- #finish ⇒ Object
-
#initialize(default_limit, max_limit = nil) ⇒ KeysetPaginationDefinition
constructor
A new instance of KeysetPaginationDefinition.
Methods inherited from ParamsReady::Parameter::StructParameterDefinition
#add_map, #ensure_canonical, #remap?
Methods inherited from ParamsReady::Parameter::AbstractStructParameterDefinition
#add_child, #child_definition, #duplicate_value, #freeze_value, #has_child?, #infer_default, #set_default
Methods inherited from ParamsReady::Parameter::Definition
#canonical_default, #default_defined?, #fetch_callable_default, #fetch_default, #memoize?, #name_for_formatter, #no_input?, #no_output?, #postprocess, #preprocess, #restricted_for_format?, #set_local, #set_no_input, #set_postprocessor, #set_preprocessor
Methods inherited from ParamsReady::Parameter::AbstractDefinition
#create, #from_hash, #from_input, #normalize_alternative_name, #parameter_class
Methods included from Extensions::Freezer
#freeze_variable, #freeze_variables, #variables_to_freeze
Methods included from Extensions::Finalizer
Methods included from Extensions::ClassReaderWriter
Methods included from Extensions::LateInit
Methods included from Extensions::Collection
Methods included from Extensions::Freezer::InstanceMethods
Constructor Details
#initialize(default_limit, max_limit = nil) ⇒ KeysetPaginationDefinition
Returns a new instance of KeysetPaginationDefinition.
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/params_ready/pagination/keyset_pagination.rb', line 187 def initialize(default_limit, max_limit = nil) super :pagination, altn: :pgn @default_limit = default_limit direction = Builder.define_symbol(:direction, altn: :dir) do constrain :enum, [:bfr, :aft] end limit = Builder.define_integer(:limit, altn: :lmt) do constrain Value::OperatorConstraint.new(:>=, MIN_LIMIT), strategy: :clamp constrain Value::OperatorConstraint.new(:<=, max_limit), strategy: :clamp unless max_limit.nil? end add_child(direction) add_child(limit) end |
Instance Attribute Details
#default_limit ⇒ Object (readonly)
Returns the value of attribute default_limit.
185 186 187 |
# File 'lib/params_ready/pagination/keyset_pagination.rb', line 185 def default_limit @default_limit end |
Instance Method Details
#finish ⇒ Object
205 206 207 208 209 |
# File 'lib/params_ready/pagination/keyset_pagination.rb', line 205 def finish keyset = names[:keyset] raise ParamsReadyError, "No cursor defined" if keyset.nil? || keyset.names.length < 1 super end |