Module: Veto

Defined in:
lib/veto.rb,
lib/veto/model.rb,
lib/veto/errors.rb,
lib/veto/version.rb,
lib/veto/validator.rb,
lib/veto/exceptions.rb,
lib/veto/blocks/block.rb,
lib/veto/checks/check.rb,
lib/veto/configuration.rb,
lib/veto/blocks/checker.rb,
lib/veto/checks/format_check.rb,
lib/veto/checks/method_check.rb,
lib/veto/check_context_object.rb,
lib/veto/checks/check_factory.rb,
lib/veto/checks/integer_check.rb,
lib/veto/checks/numeric_check.rb,
lib/veto/conditions/condition.rb,
lib/veto/blocks/validate_block.rb,
lib/veto/checks/not_null_check.rb,
lib/veto/checks/presence_check.rb,
lib/veto/conditions/conditions.rb,
lib/veto/blocks/validates_block.rb,
lib/veto/checks/attribute_check.rb,
lib/veto/checks/inclusion_check.rb,
lib/veto/checks/less_than_check.rb,
lib/veto/checks/max_length_check.rb,
lib/veto/checks/min_length_check.rb,
lib/veto/blocks/conditional_block.rb,
lib/veto/conditions/if_conditions.rb,
lib/veto/blocks/with_options_block.rb,
lib/veto/checks/exact_length_check.rb,
lib/veto/checks/greater_than_check.rb,
lib/veto/checks/length_range_check.rb,
lib/veto/conditions/proc_condition.rb,
lib/veto/conditions/condition_factory.rb,
lib/veto/conditions/passing_condition.rb,
lib/veto/conditions/unless_conditions.rb,
lib/veto/conditions/primative_condition.rb,
lib/veto/conditions/if_unless_conditions.rb,
lib/veto/conditions/entity_eval_condition.rb,
lib/veto/checks/less_than_or_equal_to_check.rb,
lib/veto/conditions/context_method_condition.rb,
lib/veto/checks/greater_than_or_equal_to_check.rb

Defined Under Namespace

Modules: Model, Validator Classes: AttributeCheck, Block, Check, CheckContextObject, CheckFactory, CheckNotAssigned, Checker, Condition, ConditionFactory, ConditionalBlock, Conditions, Configuration, ContextMethodCondition, EntityEvalCondition, Errors, ExactLengthCheck, FormatCheck, GreaterThanCheck, GreaterThanOrEqualToCheck, IfConditions, IfUnlessConditions, InclusionCheck, IntegerCheck, InvalidEntity, LengthRangeCheck, LessThanCheck, LessThanOrEqualToCheck, MaxLengthCheck, MethodCheck, MinLengthCheck, NotNullCheck, NumericCheck, PassingCondition, PresenceCheck, PrimativeCondition, ProcCondition, UnlessConditions, ValidateBlock, ValidatesBlock, VetoError, WithOptionsBlock

Constant Summary collapse

VERSION =
"1.0.1"

Class Method Summary collapse

Class Method Details

.configurationObject



40
41
42
# File 'lib/veto.rb', line 40

def self.configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields:



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

def self.configure
  yield(configuration)
end

.model(validator) ⇒ Module

Provides access to the anonymous model extension module

Examples:

class Person
 include Veto.model(PersonValidator)
end 

Parameters:

  • validator (Class)

    the Veto validator class

Returns:

  • (Module)

    the object converted into the expected format.



27
28
29
30
31
32
33
34
# File 'lib/veto.rb', line 27

def self.model validator
  mod = Module.new
  mod.define_singleton_method :included do |base|
    base.send(:include, ::Veto::Model)
    base.validates_with validator
  end
  mod
end

.validatorModule

Provides access to the anonymous validator extension module

Examples:

class PersonValidator
 include Veto.validator
end 

Returns:

  • (Module)

    the object converted into the expected format.



10
11
12
13
14
15
16
# File 'lib/veto.rb', line 10

def self.validator
  mod = Module.new
  mod.define_singleton_method :included do |base|
    base.send(:include, ::Veto::Validator)
  end
  mod
end