Module Aquarium::Aspects::DefaultObjectsHandler
In: lib/aquarium/aspects/default_objects_handler.rb

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.

Methods

Included Modules

Aquarium::Utils::ArrayUtils

Public Instance methods

[Source]

    # File lib/aquarium/aspects/default_objects_handler.rb, line 15
15:       def default_objects_given
16:         if @default_objects.nil?
17:           ary1 = make_array(@specification[:default_objects])
18:           ary2 = make_array(@specification[:default_object])
19:           @default_objects = ary1 + ary2
20:         end
21:         @default_objects
22:       end

[Source]

    # File lib/aquarium/aspects/default_objects_handler.rb, line 24
24:       def default_objects_given?
25:         not default_objects_given.empty?
26:       end

[Source]

    # File lib/aquarium/aspects/default_objects_handler.rb, line 28
28:       def use_default_objects_if_defined
29:         return unless default_objects_given?
30:         default_objects_given.each do |object|
31:           if (object.kind_of?(Class) || object.kind_of?(Module))
32:             @specification[:types] ||= []
33:             @specification[:types] << object
34:           else
35:             @specification[:objects] ||= []
36:             @specification[:objects] << object
37:           end
38:         end
39:       end

[Validate]