Sha256: 006d7b8627efa82158415317d98892398dd87b67c1b889791eeaab7c08caeb5c

Contents?: true

Size: 1.31 KB

Versions: 115

Compression:

Stored size: 1.31 KB

Contents

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


module Neo4j
  module Generators #:nodoc:
  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 'any' then 'any'
        when 'datetime' then 'DateTime'
        when 'date' then 'Date'
        when 'integer', 'number', 'fixnum' then 'Integer'
        when 'float' then 'Float'
        else
          'String'
        end
      end
    end
  end
end

Version data entries

115 entries across 115 versions & 2 rubygems

Version Path
neo4j-7.2.3 lib/rails/generators/neo4j_generator.rb
neo4j-7.2.2 lib/rails/generators/neo4j_generator.rb
neo4j-7.1.4 lib/rails/generators/neo4j_generator.rb
neo4j-7.0.16 lib/rails/generators/neo4j_generator.rb
neo4j-7.2.1 lib/rails/generators/neo4j_generator.rb
neo4j_legacy-7.2.0.2 lib/rails/generators/neo4j_generator.rb
neo4j_legacy-7.2.0.1 lib/rails/generators/neo4j_generator.rb
neo4j-7.2.0 lib/rails/generators/neo4j_generator.rb
neo4j-7.1.3 lib/rails/generators/neo4j_generator.rb
neo4j-7.0.15 lib/rails/generators/neo4j_generator.rb
neo4j-7.1.2 lib/rails/generators/neo4j_generator.rb
neo4j-7.1.1 lib/rails/generators/neo4j_generator.rb
neo4j-7.1.0 lib/rails/generators/neo4j_generator.rb
neo4j-7.0.14 lib/rails/generators/neo4j_generator.rb
neo4j-7.0.13 lib/rails/generators/neo4j_generator.rb
neo4j-7.0.12 lib/rails/generators/neo4j_generator.rb
neo4j-7.0.11 lib/rails/generators/neo4j_generator.rb
neo4j-7.0.10 lib/rails/generators/neo4j_generator.rb
neo4j-7.0.9 lib/rails/generators/neo4j_generator.rb
neo4j-7.0.8 lib/rails/generators/neo4j_generator.rb