Module: Bellmyer::ValidatesBlacklist

Defined in:
lib/bellmyer/validates_blacklist.rb

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Instance Method Summary collapse

Instance Method Details

#validates_blacklist(options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/bellmyer/validates_blacklist.rb', line 5

def validates_blacklist(options = {})
  options.reverse_merge!(
    :message  => 'is not allowed.',
    :attributes => {}
  )

  unless included_modules.include? InstanceMethods
    class_inheritable_accessor :options
    class_inheritable_accessor :model
    
    extend ClassMethods
    include InstanceMethods

    validate :model_blacklists

  end
  
  self.options = options
    self.model = self.to_s.underscore
end