Sha256: 26a87158c0a717ba1c2f42aca06f6175eca179c374c0421a78f12526424c8597

Contents?: true

Size: 747 Bytes

Versions: 1

Compression:

Stored size: 747 Bytes

Contents

module Tokamak
  module Representation
  module Atom
    class TagCollection < ::Array
      def initialize(parent_node, &block)
        @node = parent_node
        @method_missing_block = block_given? ? block : nil
        super(0)
      end
      
      def <<(obj)
        obj = [obj] unless obj.kind_of?(Array)
        obj.each do |o|
          o.doc.parent = @node
          super(o)
        end
      end
      
      def delete(obj)
        if super(obj)
          obj.doc.unlink
          obj = nil
        end
      end
      
      def method_missing(symbol, *args, &block)
        if @method_missing_block
          @method_missing_block.call(self, symbol, *args)
        else
          super
        end
      end
    end
  end
end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tokamak-1.0.0.beta2 lib/tokamak/representation/atom/tag_collection.rb