Class TTK::Strategies::Collection
In: lib/ttk/strategies/Collection.rb
Parent: Composite

Methods

Included Modules

Abstract

Public Class methods

[Source]

# File lib/ttk/strategies/Collection.rb, line 15
      def initialize ( *a, &b )
        @attributes = OHash.new
        super
      end

Public Instance methods

Create a new test, using the current loader, and add it to the collection.

[Source]

# File lib/ttk/strategies/Collection.rb, line 23
      def create ( anObject, &block )
        super do |t|
          @log.log_debug{"assign collection attributes #{@attributes.size}"}
          @attributes.each do |k,v|
            @log.log_debug{"assign attribute: #{k}"}
            next if k == :contents
            t.assign_one(k, v, true)
          end
          if @attributes.has_key? :contents
            t.assign_one(:contents, @attributes[:contents], true)
          end
          block[t] if block_given?
          @attributes.each do |k,v|
            t.reject k if t.respond_to? k and t.send(k) == v
          end
        end
      end

[Source]

# File lib/ttk/strategies/Collection.rb, line 107
      def strategyclass
        @attributes[:strategy]
      end

[Source]

# File lib/ttk/strategies/Collection.rb, line 102
      def strategyclass= ( aClass )
        @attributes[:strategy] = aClass
      end

Protected Instance methods

[Source]

# File lib/ttk/strategies/Collection.rb, line 42
      def prologue
        super
        # dump the attributes
        attr = @attributes.dup.delete_if do |k,v|
          v.nil? or v.respond_to?(:hidden) or k == :aliases
        end
        unless attr.empty?
          @log.new_node :attributes do
            attr.each { |k, v| @log[k] = v }
          end
        end
      end

[Validate]