27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/has_handle_fallback.rb', line 27
def has_handle_fallback(fallback_column, options = {})
include InstanceMethods
extend ClassMethods
class_eval do
cattr_accessor :has_handle_fallback_options
self.has_handle_fallback_options = {}
has_handle_fallback_options[:required] = options.delete(:required) || false
has_handle_fallback_options[:fallback_column] = fallback_column
has_handle_fallback_options[:handle_column] = options.delete(:handle_column) || 'handle'
has_handle_fallback_options[:validates_format] =
options.include?(:validates_format) ? options.delete(:validates_format) : true
validate :handle_is_valid
end
end
|