module HalApi::Representer::CollectionPaging
Public Instance Methods
href_url_helper(options={})
click to toggle source
refactor to use single property, :url, that can be a method name, a string, or a lambda if it is a method name, execute against self - the representer - which has local url helpers methods if it is a sym/string, but self does not respond to it, then just use that string if it is a lambda, execute in the context against the represented.parent (if there is one) or represented
# File lib/hal_api/representer/collection_paging.rb, line 56 def href_url_helper(options={}) if represented_url.nil? options = options.except(:format) result = url_for(options.merge(only_path: true)) rescue nil if represented.parent result ||= polymorphic_path([:api, represented.parent, represented.item_class], options) rescue nil end result ||= polymorphic_path([:api, represented.item_class], options) rescue nil return result end if represented_url.respond_to?(:call, true) instance_exec(options, &represented_url) elsif respond_to?(represented_url, true) send(represented_url, options) else represented_url.to_s end end
params()
click to toggle source
# File lib/hal_api/representer/collection_paging.rb, line 32 def params represented.params end
profile_url(represented)
click to toggle source
# File lib/hal_api/representer/collection_paging.rb, line 48 def profile_url(represented) model_uri(:collection, represented.item_class) end
represented_url()
click to toggle source
# File lib/hal_api/representer/collection_paging.rb, line 76 def represented_url @represented_url ||= represented.try(:url) end
self_url(represented)
click to toggle source
# File lib/hal_api/representer/collection_paging.rb, line 36 def self_url(represented) href_url_helper(represented.params) end
vary_params()
click to toggle source
# File lib/hal_api/representer/collection_paging.rb, line 44 def vary_params %w(page per zoom filters sorts) end
vary_url(represented)
click to toggle source
# File lib/hal_api/representer/collection_paging.rb, line 40 def vary_url(represented) href_url_helper(represented.params.except(*vary_params)) end