Sha256: 2b3007743a45bb7eb61ee7d20fbaab6db6ee5b1ef7de4b3323876440c6b68eca
Contents?: true
Size: 1.47 KB
Versions: 8
Compression:
Stored size: 1.47 KB
Contents
module Devise module Orm module DataMapper def self.included_modules_hook(klass, modules) klass.send :extend, self yield modules.each do |mod| klass.send(mod) if klass.respond_to?(mod) end end include Devise::Schema SCHEMA_OPTIONS = { :null => :nullable, :limit => :length } # Hooks for confirmable def before_create(*args) before :create, *args end def after_create(*args) after :create, *args end # Add ActiveRecord like finder def find(*args) options = args.extract_options! case args.first when :first first(options) when :all all(options) else get(*args) end end # In Datamapper, we need to call save! if we don't want to execute callbacks. def save(flag=nil) if flag == false save! else super() end end # Tell how to apply schema methods. This automatically maps :limit to # :length and :null to :nullable. def apply_schema(name, type, options={}) return unless Devise.apply_schema SCHEMA_OPTIONS.each do |old_key, new_key| next unless options.key?(old_key) options[new_key] = options.delete(old_key) end property name, type, options end end end end DataMapper::Model.send(:include, Devise::Models)
Version data entries
8 entries across 8 versions & 1 rubygems