Sha256: 88f6d1bf8633fcbb3fa5f9e6047cb93f9768fb9c754e128b7470c7369f8b71c9

Contents?: true

Size: 500 Bytes

Versions: 11

Compression:

Stored size: 500 Bytes

Contents

module SmartIoC::Args
  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

  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

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
smart_ioc-0.5.2 lib/smart_ioc/args.rb
smart_ioc-0.5.1 lib/smart_ioc/args.rb
smart_ioc-0.5.0 lib/smart_ioc/args.rb
smart_ioc-0.3.9 lib/smart_ioc/args.rb
smart_ioc-0.4.0 lib/smart_ioc/args.rb
smart_ioc-0.3.8 lib/smart_ioc/args.rb
smart_ioc-0.3.7 lib/smart_ioc/args.rb
smart_ioc-0.3.6 lib/smart_ioc/args.rb
smart_ioc-0.3.5 lib/smart_ioc/args.rb
smart_ioc-0.3.2 lib/smart_ioc/args.rb
smart_ioc-0.3.1 lib/smart_ioc/args.rb