Module: Sequel::Plugins::NotNaughty::ClassMethods

Defined in:
lib/sequel_not_naughty.rb

Overview

Ensures Sequel::Model API compatibility.

Instance Method Summary collapse

Instance Method Details

#has_validations?Boolean

Returns true if validations are defined.

Returns:

  • (Boolean)


118
119
120
# File 'lib/sequel_not_naughty.rb', line 118

def has_validations?()
  validator.has_validations?
end

#validate(instance) ⇒ Object

Validates the given instance.



122
123
124
# File 'lib/sequel_not_naughty.rb', line 122

def validate(instance)
  validator.invoke instance
end

#validationsObject

Returns the validations hash for the class.



111
112
113
114
115
116
# File 'lib/sequel_not_naughty.rb', line 111

def validations
  validator.states.
  inject({}) do |validations, state_with_name|
    validations.merge(state_with_name[1].validations) {|k,o,n| o|n}
  end
end