Sha256: ff9b1b1580d2768f02290c2ca9ef472df8038b5da2cceb803ada9a973e67716c

Contents?: true

Size: 784 Bytes

Versions: 4

Compression:

Stored size: 784 Bytes

Contents

module Merb::Generators
  
  class ResourceGenerator < Generator
    
    desc <<-DESC
      Generates a new resource.
    DESC
    
    first_argument :name, :required => true, :desc => "resource name (singular)"
    second_argument :attributes, :as => :hash, :default => {}, :desc => "space separated resource model properties in form of name:type. Example: state:string"
    
    invoke :model do |generator|
      generator.new(destination_root, options, model_name, attributes)
    end
    
    invoke :resource_controller do |generator|
      generator.new(destination_root, options, controller_name, attributes)
    end
    
    def controller_name
      name.pluralize
    end
    
    def model_name
      name
    end
    
  end
  
  add :resource, ResourceGenerator
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
merb-gen-0.9.5 lib/generators/resource.rb
merb-gen-0.9.6 lib/generators/resource.rb
merb-gen-0.9.7 lib/generators/resource.rb
merb-gen-0.9.8 lib/generators/resource.rb