Module: RailsDefaults::Helpers
- Defined in:
- lib/rails-defaults.rb
Class Method Summary collapse
Class Method Details
.must_be_instance_of(obj, *classes) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rails-defaults.rb', line 6 def must_be_instance_of obj, *classes var= classes.map { |class_name| if obj.class <= class_name true else nil end }.compact if var.empty? raise ArgumentError,"invalid input object, must be instance from one of these or they subclasses class: #{classes.join(', ')}" end end |