Sha256: dd19d42ab31f8f8b58c797c1800644b285dc8a11227f58400a65abc91c3fac6f

Contents?: true

Size: 1.01 KB

Versions: 7

Compression:

Stored size: 1.01 KB

Contents

module ProductHelper
  def render_product_specific_presenter_if_available(resource, partial_path, method, options = {})
    if @presenter.respond_to?(method)
      @step_presenter = @presenter.send(method) 
    else
      @step_presenter = nil
    end
    
    render_product_specific_partial_if_available(resource, "#{partial_path}/#{method}", options)
  end
  
  def render_product_specific_partial_if_available(resource, partial_path, options = {})
    path = nil
    partial_path = partial_path.split('/')
    file_name = partial_path.pop
    partial_path = partial_path.join('/')
    
    if resource && resource.respond_to?(:product) && resource.product
      path = "products/types/#{directory_for_resource(resource.product)}/#{partial_path}"
      
      path = [path, file_name].join('/')
      
      begin 
        return render(path, options)
      rescue ActionView::MissingTemplate
        path = nil
      end
    end

    path = [partial_path, file_name].join('/') if path.blank?

    render path, options 
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
voluntary-0.1.0 app/helpers/product_helper.rb
voluntary-0.1.0.rc4 app/helpers/product_helper.rb
voluntary-0.1.0.rc3 app/helpers/product_helper.rb
voluntary-0.1.0.rc2 app/helpers/product_helper.rb
voluntary-0.1.0.rc1 app/helpers/product_helper.rb
voluntary-0.0.3 app/helpers/product_helper.rb
voluntary-0.0.2 app/helpers/product_helper.rb