Sha256: e5ed6ab27293e8a6b00daa1970b10b9e4281f0588fef45fed435ebd9184c8cd9

Contents?: true

Size: 1.78 KB

Versions: 1

Compression:

Stored size: 1.78 KB

Contents

module DataMapper
  module Generators
    class DeviseInstallGenerator < ::Rails::Generators::Base
      def generate_devise_install
        invoke 'devise:install'
      end

      def inject_data_mapper_content
        devise_init_file = File.join(::Rails.root, 'config', 'initializers', 'devise.rb')
        validations = <<VALIDATIONS
  # ==> Validations Library
  # dm-devise adds some compatibility methods for either dm-validations or
  # Active Model validations. By default, it determines what to load based on
  # which library is found (giving preference to dm-validations). You may
  # explicitly set this to 'dm-validations' or 'active_model', or false to not
  # load any of the validations compatibility code.
  # config.data_mapper_validation_lib = nil

VALIDATIONS
        inject_into_file devise_init_file, validations, :before => '  # ==> ORM configuration'

        data_mapper_options = <<APPLY_SCHEMA

  # ==> Apply Schema
  # Tells if dm-devise should apply the devise database schema via property
  # declarations. You may want to set this to false if working with a legacy
  # schema.
  # config.apply_schema = true

  # ==> dm-validations Default Error Messages
  # Messages to use as the default DataMapper validation error messages. The
  # messages are updated from those included in dm-validations to be consistent
  # with ActiveModel (i.e. with the Devise test expectations) and include
  # additional messages that devise uses (:not_found, :already_confirmed,
  # :not_locked, and :expired). If set to false, the messages are left as
  # defined by the dm-validations gem. See dm-devise.rb for default.
  # config.data_mapper_validation_messages = {}
APPLY_SCHEMA
      inject_into_file devise_init_file, data_mapper_options, :after => "orm/data_mapper'\n"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dm-devise-2.0.1 lib/generators/data_mapper/devise_install_generator.rb