Sha256: 5f2bd5b4eda5ef0ec648154766a4b9141642bb879c165234340fa50572506bd1

Contents?: true

Size: 1.27 KB

Versions: 2

Compression:

Stored size: 1.27 KB

Contents

require 'rails/generators/resource_helpers'
require 'generators/resty/base'
module Resty
  module Generators
    class ScaffoldGenerator < Base
      include Rails::Generators::ResourceHelpers

      source_root File.expand_path('../../templates', __FILE__)
      
      argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"

      if defined? ::Ixtlan::ModifiedBy
        class_option :modified_by, :type => :boolean
      end
      class_option :timestamps, :type => :boolean
      class_option :parent,     :type => :string, :desc => "The parent class for the generated model"
      class_option :singleton,  :type => :boolean

      def create_model_file
        template 'Model.java', File.join(java_root, models_base_package.gsub(/\./, "/"), class_path, "#{class_name}.java")
      end

      def create_controller_file
        template 'Controller.java', File.join(java_root, controllers_base_package.gsub(/\./, "/"), class_path, "#{controller_class_name}Controller.java")
      end

      def actions
        if options[:singleton]
          keys = action_map.keys
          keys.delete('index')
          keys.delete('create')
          keys.delete('destroy')
          keys
        else
          action_map.keys
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
resty-generators-0.2.0 lib/generators/resty/scaffold/scaffold_generator.rb
resty-generators-0.1.0 lib/generators/resty/scaffold/scaffold_generator.rb