Some classes support a :default_objects
option and use it if
no type or object is specified. In other words, the
:default_objects
option is ignored if :types
or
:objects
is present. This module handles this behavior for all
the classes that include it. These classes are assumed to have
@specification
defined with keys
:default_objects
, :types
, and
:objects
.
# File lib/aquarium/aspects/default_objects_handler.rb, line 15 def default_objects_given if @default_objects.nil? ary1 = make_array(@specification[:default_objects]) ary2 = make_array(@specification[:default_object]) @default_objects = ary1 + ary2 end @default_objects end
# File lib/aquarium/aspects/default_objects_handler.rb, line 24 def default_objects_given? not default_objects_given.empty? end
# File lib/aquarium/aspects/default_objects_handler.rb, line 28 def use_default_objects_if_defined return unless default_objects_given? default_objects_given.each do |object| if (object.kind_of?(Class) || object.kind_of?(Module)) @specification[:types] ||= [] @specification[:types] << object else @specification[:objects] ||= [] @specification[:objects] << object end end end