Class: EPlat::Paginated::LinkParams

Inherits:
Object
  • Object
show all
Defined in:
lib/e_plat/resource/paginated/link_params.rb

Defined Under Namespace

Classes: LinkParam

Instance Attribute Summary collapse

Instance Method Summary collapse

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

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

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