Module: Validate::Arguments::ClassMethods

Defined in:
lib/validate/arguments.rb

Instance Method Summary collapse

Instance Method Details

#arg(name, &body) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/validate/arguments.rb', line 14

def arg(name, &body)
  if @args.include?(name)
    raise Error::ArgumentError, "duplicate argument :#{name}"
  end

  @args[name] = Assertions.create(&body)
  self
end

#method_added(method_name) ⇒ Object



4
5
6
7
# File 'lib/validate/arguments.rb', line 4

def method_added(method_name)
  super
  guard_method(instance_method(method_name), @methods_guard)
end

#singleton_method_added(method_name) ⇒ Object



9
10
11
12
# File 'lib/validate/arguments.rb', line 9

def singleton_method_added(method_name)
  super
  guard_method(singleton_method(method_name), @singleton_methods_guard)
end