Sha256: 1b438548c32cbac88bcc4d75183e0ffc0c932f13714e560eea5df8fe31dec5bc

Contents?: true

Size: 456 Bytes

Versions: 13

Compression:

Stored size: 456 Bytes

Contents

class Factory
  class << self
    def factories
      @@factories ||= {}
    end
    
    def define(type, attributes)
      factories[type] = attributes
    end
  end
end


def Factory(type, attrs = {})
  defaults = Factory.factories[type]
  attrs = defaults.merge(attrs)
  
  markup = Builder::XmlMarkup.new
  markup.__send__(type) do
    attrs.each do |attribute, value|
      markup.__send__(attribute, value.to_s)
    end
  end
  
  markup.target!
end

Version data entries

13 entries across 13 versions & 4 rubygems

Version Path
git-pivotal-tracker-centro-1.0.0.rc3 spec/factory.rb
git-pivotal-tracker-centro-1.0.0.rc2 spec/factory.rb
git-pivotal-tracker-centro-1.0.0.rc1 spec/factory.rb
git-pivotal-tracker-0.9.1 spec/factory.rb
git-pivotal-tracker-0.9.0 spec/factory.rb
git-pivotal-0.8.2 spec/factory.rb
git-pivotal-0.8.0 spec/factory.rb
git-pivotal-0.2.3 spec/factory.rb
idealian-git-pivotal-0.2.4 spec/factory.rb
idealian-git-pivotal-0.2.3 spec/factory.rb
git-pivotal-0.2.2 spec/factory.rb
git-pivotal-0.2.1 spec/factory.rb
git-pivotal-0.2.0 spec/factory.rb