Sha256: 67df04848a5e8959262a8cf302807a723eb0583c9d82de6a9e75e4c1408045e4

Contents?: true

Size: 1.2 KB

Versions: 13

Compression:

Stored size: 1.2 KB

Contents

<%
controller_code = <<-RUBY
class #{@controller_name} < ApplicationController
  def index; end

  def show
    op Operations#{ "::#{@module_name}" if @module_name.present? }::#{@class_name}::Load
  end

  def new
    op Operations#{ "::#{@module_name}" if @module_name.present? }::#{@class_name}::Create
  end

  def create
    if run Operations#{ "::#{@module_name}" if @module_name.present? }::#{@class_name}::Create
      # handle successful case
    else
      # handle error case
    end
  end

  def edit
    op Operations#{ "::#{@module_name}" if @module_name.present? }::#{@class_name}::Update
  end

  def update
    if run Operations#{ "::#{@module_name}" if @module_name.present? }::#{@class_name}::Update
      # handle successful case
    else
      # handle error case
    end
  end

  def destroy
    if run Operations#{ "::#{@module_name}" if @module_name.present? }::#{@class_name}::Destroy
      # handle successful case
    else
      # handle error case
    end
  end
end
RUBY
-%>
<% if @module_name.present? -%>
module <%= @module_name %>
<% controller_code.split("\n").each do |line| -%>
<% if line.blank? -%>

<% else -%>
  <%= line %>
<% end -%>
<% end -%>
end
<% else -%>
<%= controller_code -%>
<% end -%>

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rails_ops-1.4.2 lib/generators/operation/templates/controller.erb
rails_ops-1.4.1 lib/generators/operation/templates/controller.erb
rails_ops-1.4.0 lib/generators/operation/templates/controller.erb
rails_ops-1.3.0 lib/generators/operation/templates/controller.erb
rails_ops-1.2.3 lib/generators/operation/templates/controller.erb
rails_ops-1.2.2 lib/generators/operation/templates/controller.erb
rails_ops-1.2.1 lib/generators/operation/templates/controller.erb
rails_ops-1.2.0 lib/generators/operation/templates/controller.erb
rails_ops-1.1.31 lib/generators/operation/templates/controller.erb
rails_ops-1.1.30 lib/generators/operation/templates/controller.erb
rails_ops-1.1.29 lib/generators/operation/templates/controller.erb
rails_ops-1.1.28 lib/generators/operation/templates/controller.erb
rails_ops-1.1.27 lib/generators/operation/templates/controller.erb