Class: Sequel::Plugins::NotNaughty

Inherits:
NotNaughty::Validator
  • Object
show all
Defined in:
lib/sequel_notnaughty.rb

Overview

Adapter for Ruby Sequel

Validate all your Ruby Sequel models with NotNaughty:

class Sequel::Model
  is :notnaughty
end

Validate just specific models:

class YourModel < Sequel::Model
  is :notnaughty
end

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.apply(receiver, *args) ⇒ Object

Hook called by plugin api.



30
31
32
33
# File 'lib/sequel_notnaughty.rb', line 30

def self.apply(receiver, *args)
  receiver.extend ::NotNaughty
  receiver.validator self, :create, :update
end

Instance Method Details

#get_state(instance) ⇒ Object

Returns state for given instance.



36
37
38
# File 'lib/sequel_notnaughty.rb', line 36

def get_state(instance)
  if instance.new? then @states[:create] else @states[:update] end
end