11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/fast_exists/active_record/extension.rb', line 11
def fast_exists(*attributes)
options = attributes.
class_attribute :fast_exists_attributes, default: {} unless respond_to?(:fast_exists_attributes)
attributes.map(&:to_sym).each do |attr|
self.fast_exists_attributes = fast_exists_attributes.merge(attr => options)
singleton_class.define_method("#{attr}_exists?") do |value|
fast_exists?(attr, value)
end
singleton_class.define_method("#{attr}_available?") do |value|
fast_available?(attr, value)
end
end
extend FastExists::ActiveRecord::ModelMethods
include FastExists::ActiveRecord::Hooks
end
|