Class: Waw::Validation::Signature::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/waw/validation/signature.rb

Overview

The DSL attached to signature

Instance Method Summary collapse

Constructor Details

#initialize(signature) ⇒ DSL

Creates a DSL instance



12
13
14
# File 'lib/waw/validation/signature.rb', line 12

def initialize(signature)
  @signature = signature
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object

When a methos is missing



30
31
32
33
34
# File 'lib/waw/validation/signature.rb', line 30

def method_missing(name, *args, &block)
  Waw::Validation.send(name, *args, &block)
rescue Exception => ex
  raise ex.class, ex.message, caller
end

Instance Method Details

#execute(&block) ⇒ Object

Executes a block as this DSL



17
18
19
20
21
22
# File 'lib/waw/validation/signature.rb', line 17

def execute(&block)
  DSLHelper.new(Class => [:&, :|, :not]) do
    Kernel.load(File.join(File.dirname(__FILE__), 'dsl_ruby_extensions.rb'))
    self.instance_eval(&block)
  end
end

#validation(args, validator, onfailure) ⇒ Object

Adds a validation



25
26
27
# File 'lib/waw/validation/signature.rb', line 25

def validation(args, validator, onfailure)
  @signature.add_validation(args, ::Waw::Validation.to_validator(validator), onfailure)
end