Class: JSONAPIonify::Api::Resource::Builders::CursorBuilder
- Inherits:
-
BaseBuilder
- Object
- BaseBuilder
- JSONAPIonify::Api::Resource::Builders::CursorBuilder
- Defined in:
- lib/jsonapionify/api/resource/builders/cursor_builder.rb
Constant Summary
Constants included from Structure
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#instance ⇒ Object
readonly
Returns the value of attribute instance.
Attributes inherited from BaseBuilder
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(resource, instance:, context:) ⇒ CursorBuilder
constructor
A new instance of CursorBuilder.
Methods inherited from BaseBuilder
Constructor Details
#initialize(resource, instance:, context:) ⇒ CursorBuilder
Returns a new instance of CursorBuilder.
10 11 12 13 14 |
# File 'lib/jsonapionify/api/resource/builders/cursor_builder.rb', line 10 def initialize(resource, instance:, context:) super(resource) @instance = instance @context = context end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
5 6 7 |
# File 'lib/jsonapionify/api/resource/builders/cursor_builder.rb', line 5 def context @context end |
#instance ⇒ Object (readonly)
Returns the value of attribute instance.
5 6 7 |
# File 'lib/jsonapionify/api/resource/builders/cursor_builder.rb', line 5 def instance @instance end |
Instance Method Details
#build ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/jsonapionify/api/resource/builders/cursor_builder.rb', line 16 def build sort_string = params['sort'] sort_fields = sort_fields_from_sort_string(sort_string) attrs_with_values = sort_fields.each_with_object({}) do |field, hash| hash[field.name] = instance.send(field.name) end Base64.urlsafe_encode64(JSON.dump( { t: resource_type, s: sort_string, a: attrs_with_values } )) end |