Sha256: 375e6b65bbeb58504ab00b1178abf9f58c73e0dbdb367a8bbb042f8236d78691

Contents?: true

Size: 906 Bytes

Versions: 5

Compression:

Stored size: 906 Bytes

Contents

module Restfulie
  module Common
    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
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
restfulie-1.0.0.beta1 lib/restfulie/common/representation/atom/tag_collection.rb
restfulie-0.1.0.beta1 lib/restfulie/common/representation/atom/tag_collection.rb
restfulie-0.9.3 lib/restfulie/common/representation/atom/tag_collection.rb
restfulie-0.9.1 lib/restfulie/common/representation/atom/tag_collection.rb
restfulie-0.8.1 lib/restfulie/common/representation/atom/tag_collection.rb