Sha256: ac173f1619c94ada38587ac254f5c3fc5c18311d0a01b59e504f893469f79d69

Contents?: true

Size: 1.16 KB

Versions: 7

Compression:

Stored size: 1.16 KB

Contents

require 'rails/generators/rails/scaffold_controller/scaffold_controller_generator'

module Rails
  module Generators
    class RespondersControllerGenerator < ScaffoldControllerGenerator
      source_root File.expand_path("../templates", __FILE__)

      protected

      def flash?
        if defined?(ApplicationController)
          !ApplicationController.responder.ancestors.include?(Responders::FlashResponder)
        else
          Rails.application.config.responders.flash_keys.blank?
        end
      end

      def orm_instance_update(params)
        if orm_instance.respond_to?(:update)
          orm_instance.update params
        else
          orm_instance.update_attributes params
        end
      end

      def controller_before_filter
        if ActionController::Base.respond_to?(:before_action)
          "before_action"
        else
          "before_filter"
        end
      end

      def attributes_params
        if strong_parameters_defined?
          "#{file_name}_params"
        else
          "params[:#{file_name}]"
        end
      end

      def strong_parameters_defined?
        defined?(ActionController::StrongParameters)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
responders-1.1.2 lib/generators/rails/responders_controller_generator.rb
responders-2.0.2 lib/generators/rails/responders_controller_generator.rb
responders-2.0.1 lib/generators/rails/responders_controller_generator.rb
responders-1.1.1 lib/generators/rails/responders_controller_generator.rb
responders-2.0.0 lib/generators/rails/responders_controller_generator.rb
responders-1.1.0 lib/generators/rails/responders_controller_generator.rb
responders-1.0.0 lib/generators/rails/responders_controller_generator.rb