Class: EPlat::Paginated::LinkParams
- Inherits:
-
Object
- Object
- EPlat::Paginated::LinkParams
- Defined in:
- lib/e_plat/resource/paginated/link_params.rb
Defined Under Namespace
Classes: LinkParam
Instance Attribute Summary collapse
-
#next_link ⇒ Object
readonly
Returns the value of attribute next_link.
-
#previous_link ⇒ Object
readonly
Returns the value of attribute previous_link.
Instance Method Summary collapse
-
#initialize(link_params) ⇒ LinkParams
constructor
“current”=>“?include=variants%2Cimages&limit=2&page=1”.
Constructor Details
#initialize(link_params) ⇒ LinkParams
“current”=>“?include=variants%2Cimages&limit=2&page=1”
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/e_plat/resource/paginated/link_params.rb', line 11 def initialize(link_params) #{"next"=>"?include=variants%2Cimages&limit=2&page=2", "current"=>"?include=variants%2Cimages&limit=2&page=1"} links = link_params.map do |key, value| if key == "next" LinkParam.new(rel: key.to_sym, url: value) else key == "previous" LinkParam.new(rel: key.to_sym, url: value) end end @previous_link = links.find { |link| link.rel == :previous } @next_link = links.find { |link| link.rel == :next } end |
Instance Attribute Details
#next_link ⇒ Object (readonly)
Returns the value of attribute next_link.
9 10 11 |
# File 'lib/e_plat/resource/paginated/link_params.rb', line 9 def next_link @next_link end |
#previous_link ⇒ Object (readonly)
Returns the value of attribute previous_link.
9 10 11 |
# File 'lib/e_plat/resource/paginated/link_params.rb', line 9 def previous_link @previous_link end |