Module: Ixtlan::Generators::Singleton

Included in:
ActiveRecord::Generators::ModelGenerator
Defined in:
lib/ixtlan/railtie.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ixtlan/railtie.rb', line 5

def self.included(base)
  base.class_eval do
    class_option :singleton, :type => :boolean, :default => false

    if self.class.to_s =~  /ScaffoldGenerator$/

      protected
      alias :available_views_old :available_views
      def available_views
        if options[:singleton]
          %w(new create edit show destroy _form)
        else
          available_views_old
        end
      end

    end
  end
end