Sha256: 4eb566e195a1d0bc42a744ff265034cb73b91ea800e64687be2be60b2fd23a88

Contents?: true

Size: 462 Bytes

Versions: 1

Compression:

Stored size: 462 Bytes

Contents

module AhcHelper

  def render_ahc(template)
    if params[:format] == 'json'
      render json: @data
    else
      render text: Ahc.render(template, @data)
    end
  end

end

module AhcInheritedResourcesHelper
  include AhcHelper

  def respond_with(*resources, &block)
    controller = params[:controller].split('/').last
    action = params[:action]
    @data ||= {}
    @data['resources'] = collection
    render_ahc("#{controller}/#{action}")
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ahc-0.3.0 lib/ahc_helper.rb