Sha256: 1312808cb023280cfd99dd567b9365311e8f3c4869cbeed3b1a452362f5235a1

Contents?: true

Size: 1.22 KB

Versions: 7

Compression:

Stored size: 1.22 KB

Contents

require 'rails/generators/named_base'
require 'rails/generators/active_model'

module Neo4j
	module Generators
	end
end

class Neo4j::Generators::Base < Rails::Generators::NamedBase #:nodoc:
	def self.source_root
		@_neo4j_source_root ||= File.expand_path(File.join(File.dirname(__FILE__),
			'neo4j', generator_name, 'templates'))
	end
end

class Neo4j::Generators::ActiveModel < Rails::Generators::ActiveModel #:nodoc:
	def self.all(klass)
		"#{klass}.all"
	end

	def self.find(klass, params=nil)
		"#{klass}.find(#{params})"
	end

	def self.build(klass, params=nil)
		if params
			"#{klass}.new(#{params})"
		else
			"#{klass}.new"
		end
	end

	def save
		"#{name}.save"
	end

	def update_attributes(params=nil)
		"#{name}.update_attributes(#{params})"
	end

	def errors
		"#{name}.errors"
	end

	def destroy
		"#{name}.destroy"
	end
end

module Rails
  module Generators
    class GeneratedAttribute #:nodoc:
      def type_class
      	case type.to_s.downcase
					when 'datetime' 										then 'DateTime'
					when 'date' 												then 'Date'
					when 'text' 												then 'String'
					when 'integer', 'number', 'fixnum' 	then 'Fixnum'
					when 'float' 												then 'Float'
					else 'String'
      	end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
neo4j-1.0.0.beta.24-java lib/generators/neo4j.rb
neo4j-1.0.0.beta.23-java lib/generators/neo4j.rb
neo4j-1.0.0.beta.22-java lib/generators/neo4j.rb
neo4j-1.0.0.beta.21-java lib/generators/neo4j.rb
neo4j-1.0.0.beta.20 lib/generators/neo4j.rb
neo4j-1.0.0.beta.19 lib/generators/neo4j.rb
neo4j-1.0.0.beta.18 lib/generators/neo4j.rb