Module: Ree::Args
- Included in:
- Ree, BuildPackageDsl, Container, Contracts::Engine, Contracts::MethodDecorator, LinkDSL::ClassMethods, ObjectDsl, PackagesFacade, ReeGem
- Defined in:
- lib/ree/args.rb
Instance Method Summary collapse
- #check_arg(value, name, klass) ⇒ Object
- #check_arg_any(value, name, klasses) ⇒ Object
- #check_arg_array_of(value, name, klass) ⇒ Object
- #check_bool(value, name) ⇒ Object
- #not_nil(value, name) ⇒ Object
Instance Method Details
#check_arg(value, name, klass) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/ree/args.rb', line 4 def check_arg(value, name, klass) if !value.is_a?(klass) raise Ree::Error.new( ":#{name} should be a #{klass}. Got #{value.class}: #{Ree::StringUtils.truncate(value.inspect)}", :invalid_arg ) end end |
#check_arg_any(value, name, klasses) ⇒ Object
23 24 25 26 27 |
# File 'lib/ree/args.rb', line 23 def check_arg_any(value, name, klasses) if !klasses.detect {|klass| value.is_a?(klass)} raise Ree::Error.new(":#{name} should be any of #{klasses.inspect}", :invalid_arg) end end |
#check_arg_array_of(value, name, klass) ⇒ Object
17 18 19 20 21 |
# File 'lib/ree/args.rb', line 17 def check_arg_array_of(value, name, klass) if !value.is_a?(Array) && value.detect { |_| !_.is_a?(Symbol)} raise Ree::Error.new(":#{name} should be array of #{klass.inspect}. Got #{value.class}: #{Ree::StringUtils.truncate(value.inspect)}", :invalid_arg) end end |
#check_bool(value, name) ⇒ Object
13 14 15 |
# File 'lib/ree/args.rb', line 13 def check_bool(value, name) check_arg_any(value, name, [TrueClass, FalseClass]) end |