Sha256: 865e1c04ef1c20d6c07df6ac5f4e709415d1f46bf58eb8bc4a05863028ee44d5

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

module <%= class_name %><%= step_alias.pluralize.camelize %>Helper
  <%= step_alias.pluralize.upcase %> = %w(<%= steps.to_a.join(' ') %>)

  def <%= file_path %>_<%= step_alias %>_model
    <%= file_path %>_class = "<%= class_name %>::#{<%= step_alias %>.camelcase}".constantize rescue <%= class_name %>
    <%= file_path %>_class.find(params[:<%= file_path %>_id])
  end

  def <%= step_alias %>
    <%= step_alias.pluralize.upcase %>.find {|a_<%= step_alias %>| a_<%= step_alias %> == params[:id].to_s.downcase}
  end

  def next_<%= step_alias %>
    current_<%= step_alias %>_index = <%= step_alias.pluralize.upcase %>.index(<%= step_alias %>)
    <%= step_alias.pluralize.upcase %>[current_<%= step_alias %>_index+1]
  end

  def previous_<%= step_alias %>
    current_<%= step_alias %>_index = <%= step_alias.pluralize.upcase %>.index(<%= step_alias %>)
    previous_<%= step_alias %>_index = current_<%= step_alias %>_index-1
    previous_<%= step_alias %>_index < 0 ? nil : <%= step_alias.pluralize.upcase %>[previous_<%= step_alias %>_index]
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ultra_light_wizard-0.0.2 lib/generators/templates/app/helpers/wizard_steps_helper.rb.erb