Module: CollectionJson::Rails::Support

Included in:
Serializer, Serializer::Items
Defined in:
lib/collection_json_rails/support.rb

Instance Method Summary collapse

Instance Method Details

#rewrite_href_of(hash) ⇒ Object



11
12
13
14
15
16
# File 'lib/collection_json_rails/support.rb', line 11

def rewrite_href_of(hash)
  params = hash.extract_params
  href = route(params[:properties][:href])
  hash[params[:name]][:href] = href
  hash
end

#route(href) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/collection_json_rails/support.rb', line 3

def route(href)
  if href.is_a?(Symbol)
    ::Rails.application.routes.url_helpers.send(href)
  else
    href
  end
end