Sha256: 42e99f6fbe459e4320651a4cfbd6ba742044d6c077df8f92529dba8064b93619

Contents?: true

Size: 691 Bytes

Versions: 4

Compression:

Stored size: 691 Bytes

Contents

# Provides macros to quickly configure a resource_controller.
# origin: RM
module BoringControllerTrait::HelpersTrait
  as_trait do |options|
  
    if options[:show_is_edit]
      for action in [:show, :update, :create] do
        send(action).wants.html do
          redirect_to edit_object_path
        end
      end
    end

    if options[:for_forms]
      before_filter :only => [:new, :create, :edit, :update] do |c|
        c.send(options[:for_forms])
      end
    end

    private

    if options[:model_name]

      define_method :model_name do
        options[:model_name]
      end

      define_method :object_name do
        options[:model_name]
      end

    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
serum-rails-0.2.1 spec/test_apps/rails-2-3/app/controllers/shared/boring_controller_trait/helpers_trait.rb
serum-rails-0.2.0 spec/test_apps/rails-2-3/app/controllers/shared/boring_controller_trait/helpers_trait.rb
serum-rails-0.1.1 spec/test_app/app/controllers/shared/boring_controller_trait/helpers_trait.rb
serum-rails-0.1.0 spec/test_app/app/controllers/shared/boring_controller_trait/helpers_trait.rb