extend AR by default if present

This commit is contained in:
Adam Meehan 2010-08-31 22:43:40 +10:00
parent 53f3d876ea
commit 10f49144c3
2 changed files with 6 additions and 5 deletions

View File

@ -38,16 +38,17 @@ Then run
rails generate validates_timeliness:install
This creates configuration initializer and locale files. In the initializer, you need to uncomment the extend_classes setting like so
This creates configuration initializer and locale files. In the initializer, you there are a number of config options to customize the plugin.
ValidatesTimeliness.setup do |config|
config.extend_classes = [ ActiveRecord::Base ]
# Add validation helpers to these classes
# config.extend_classes = [ ActiveRecord::Base ]
end
This adds the validation helper methods to ActiveRecord. Replace it with the ORM of your choosing.
As long as it supports ActiveModel it should work.
By default the plugin extends ActiveRecord if present. If you are using one or more other ORMs, you need to add them to this config option array.
As long as the ORM supports ActiveModel it should work.
== Usage:

View File

@ -17,7 +17,7 @@ module ValidatesTimeliness
# Add validation helpers to these classes
mattr_accessor :extend_classes
@@extend_classes = []
@@extend_classes = [ defined?(ActiveRecord) && ActiveRecord::Base ].compact
# Set the dummy date part for a time type values.
mattr_accessor :dummy_date_for_time_type