Module: SmartIoC::Args

Included in:
BeanDefinition, BeanFactory, BeanLocator, Container, ExtraPackageContexts
Defined in:
lib/smart_ioc/args.rb

Instance Method Summary collapse

Instance Method Details

#check_arg(value, name, klass) ⇒ Object



2
3
4
5
6
# File 'lib/smart_ioc/args.rb', line 2

def check_arg(value, name, klass)
  if !value.is_a?(klass)
    raise ArgumentError, ":#{name} should be a #{klass}. Got #{value.class}: #{value.inspect}"
  end
end

#check_arg_any(value, name, klasses) ⇒ Object



8
9
10
11
12
# File 'lib/smart_ioc/args.rb', line 8

def check_arg_any(value, name, klasses)
  if !klasses.detect {|klass| value.is_a?(klass)}
    raise ArgumentError, ":#{name} should be any of #{klasses.inspect}"
  end
end

#not_nil(value, name) ⇒ Object



14
15
16
17
18
# File 'lib/smart_ioc/args.rb', line 14

def not_nil(value, name)
  if value.nil?
    raise ArgumentError, ":#{name} should not be blank"
  end
end