Sha256: 6e8f6bf0c95552049dce70e42f2a421f4837915b19e4c6e29bf14407f6119ef6

Contents?: true

Size: 1.12 KB

Versions: 7

Compression:

Stored size: 1.12 KB

Contents

module Haml
  module Generators
    class ActsAsApprovableGenerator < Rails::Generators::Base
      source_root File.expand_path('../templates', __FILE__)

      class_option :owner, :type => :string, :optional => true, :desc => 'Model that can own approvals'

      def copy_view_files
        template 'index.html.haml',          'app/views/approvals/index.html.haml'
        template '_table.html.haml',         'app/views/approvals/_table.html.haml'
        template '_owner_select.html.haml',  'app/views/approvals/_owner_select.html.haml' if owner?
      end

      protected
      def format
        :html
      end

      def handler
        :haml
      end

      def filename_with_extensions(name)
        [name, format, handler].compact.join('.')
      end

      def owner?
        options[:owner].present?
      end

      def collection_actions
        actions = [:index, :history]
        actions << :mine if owner?
        actions.map { |a| ":#{a}" }
      end

      def member_actions
        actions = [:approve, :reject]
        actions << :assign if owner?
        actions.map { |a| ":#{a}" }
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
acts-as-approvable-0.6.4 lib/generators/haml/acts_as_approvable_generator.rb
acts-as-approvable-0.6.3.3 lib/generators/haml/acts_as_approvable_generator.rb
acts-as-approvable-0.6.3.2 lib/generators/haml/acts_as_approvable_generator.rb
acts-as-approvable-0.6.3.1 lib/generators/haml/acts_as_approvable_generator.rb
acts-as-approvable-0.6.3 lib/generators/haml/acts_as_approvable_generator.rb
acts-as-approvable-0.6.2 lib/generators/haml/acts_as_approvable_generator.rb
acts-as-approvable-0.6.1 lib/generators/haml/acts_as_approvable_generator.rb