<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -3,14 +3,29 @@ module Vanity
 
     # Base class that all experiment types are derived from.
     class Base
-      def initialize(name, &amp;block)
-        @name = name.to_s
-        @namespace = &quot;#{Vanity.playground.namespace}:experiments:#{name.downcase.gsub(/\W/, &quot;_&quot;)}&quot;
+
+      class &lt;&lt; self
+        # Type is a symbol derived from class name (e.g. AbTest becomes ab_test).
+        def type
+          name.split(&quot;::&quot;).last.gsub(/([a-z])([A-Z])/) { &quot;#{$1}_#{$2}&quot; }.gsub(/([A-Z])([A-Z][a-z])/) { &quot;#{$1}_#{$2}&quot; }.downcase
+        end
+      end
+
+      def initialize(id, name, &amp;block)
+        @id, @name = id.to_sym, name
+        @namespace = &quot;#{Vanity.playground.namespace}:experiments:#{@id}&quot;
         created = redis.get(key(:created_at)) || (redis.setnx(key(:created_at), Time.now.to_i) ; redis.get(key(:created_at))) 
         @created_at = Time.at(created.to_i)
       end
 
-      attr_reader :name, :created_at
+      # Human readable experiment name, supplied during creation.
+      attr_reader :name
+
+      # Unique identifier, derived from name, e.g. &quot;Green Button&quot; become :green_button.
+      attr_reader :id
+      
+      # Time stamp when experiment first created in database.
+      attr_reader :created_at
      
       # Sets of returs description. For example
       #   experiment :simple do
@@ -26,6 +41,10 @@ module Vanity
       def save #:nodoc:
       end
 
+      def type
+        self.class.name.split(&quot;::&quot;).last.gsub(/([a-z])([A-Z])/) { &quot;#{$1}_#{$2}&quot; }.gsub(/([A-Z])([A-Z][a-z])/) { &quot;#{$1}_#{$2}&quot; }.downcase
+      end
+
     protected
 
       # Returns key for this experiment or with additional name, e.g.</diff>
      <filename>lib/vanity/experiment/base.rb</filename>
    </modified>
    <modified>
      <diff>@@ -26,20 +26,15 @@ module Vanity
     # Defines a new experiment. Generally, do not call this directly,
     # use #experiment instead.
     def define(name, options = nil, &amp;block)
-      name = name.to_s.downcase.gsub(/\W/, &quot;_&quot;)
-      raise &quot;Experiment #{name} already defined once&quot; if @experiments[name]
-      yaml = redis.get(&quot;#{namespace}:experiments:#{name}&quot;)
-      if yaml
-        experiment = YAML.load(yaml)
-      else
-        options ||= {}
-        type = options[:type] || :ab_test
-        klass = Experiment.const_get(type.to_s.gsub(/\/(.?)/) { &quot;::#{$1.upcase}&quot; }.gsub(/(?:^|_)(.)/) { $1.upcase })
-        experiment = klass.new(name)
-      end
+      id = name.to_s.downcase.gsub(/\W/, &quot;_&quot;)
+      raise &quot;Experiment #{id} already defined once&quot; if @experiments[id]
+      options ||= {}
+      type = options[:type] || :ab_test
+      klass = Experiment.const_get(type.to_s.gsub(/\/(.?)/) { &quot;::#{$1.upcase}&quot; }.gsub(/(?:^|_)(.)/) { $1.upcase })
+      experiment = klass.new(id, name)
       experiment.instance_eval &amp;block
       experiment.save
-      @experiments[name] = experiment
+      @experiments[id] = experiment
     end
 
     # Returns the named experiment. You may not have guessed, but this method
@@ -49,11 +44,11 @@ module Vanity
     # non-word characters with underscores, so &quot;Green call to action&quot; becomes
     # &quot;green_call_to_action&quot;. You can also use a symbol if you feel like it.
     def experiment(name)
-      name = name.to_s.downcase.gsub(/\W/, &quot;_&quot;)
-      unless @experiments.has_key?(name)
-        require &quot;experiments/#{name}&quot;
+      id = name.to_s.downcase.gsub(/\W/, &quot;_&quot;)
+      unless @experiments.has_key?(id)
+        require &quot;experiments/#{id}&quot;
       end
-      @experiments[name] or fail LoadError, &quot;Expected experiments/#{name}.rb to define experiment #{name}&quot;
+      @experiments[id] or fail LoadError, &quot;Expected experiments/#{id}.rb to define experiment #{name}&quot;
     end
 
   end</diff>
      <filename>lib/vanity/playground.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,25 @@
 require &quot;test/test_helper&quot;
 
 class ExperimentTest &lt; MiniTest::Spec
+  it &quot;creates ID from name&quot; do
+    exp = experiment(&quot;Green Button/Alert&quot;) { }
+    assert_equal &quot;Green Button/Alert&quot;, exp.name
+    assert_equal :green_button_alert, exp.id
+  end
+
+  it &quot;evalutes definition block at creation&quot; do
+    experiment :green_button do
+      expects(:xmts).returns(&quot;x&quot;)
+    end
+    assert_equal &quot;x&quot;, experiment(:green_button).xmts
+  end
+
+  it &quot;saves experiments after defining it&quot; do
+    experiment :green_button do
+      expects(:save)
+    end
+  end
+
   it &quot;stores when experiment created&quot; do
     experiment(:simple) { }
     assert_instance_of Time, experiment(:simple).created_at</diff>
      <filename>test/experiment_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -49,9 +49,11 @@ class PlaygroundTest &lt; MiniTest::Spec
   it &quot;returns experiment defined in file&quot; do
     playground = class &lt;&lt; Vanity.playground ; self ; end
     playground.send :define_method, :require do |file|
-      Vanity.playground.define(&quot;Green Button&quot;) { }
+      Vanity.playground.define &quot;Green Button&quot; do
+        def xmts ; &quot;x&quot; ; end
+      end
     end
-    assert_equal &quot;green_button&quot;, experiment(&quot;Green button&quot;).name
+    assert_equal &quot;x&quot;, experiment(&quot;Green button&quot;).xmts
   end
 
   it &quot;can define and access experiment using symbol&quot; do
@@ -68,19 +70,6 @@ class PlaygroundTest &lt; MiniTest::Spec
     end
   end
 
-  it &quot;evalutes definition block when creating experiment&quot; do
-    experiment :green_button do
-      expects(:xmts).returns(&quot;x&quot;)
-    end
-    assert_equal &quot;x&quot;, experiment(:green_button).xmts
-  end
-
-  it &quot;saves experiments after defining it&quot; do
-    experiment :green_button do
-      expects(:save)
-    end
-  end
-
   it &quot;uses playground namespace in experiment&quot; do
     experiment(:green_button) { }
     assert_equal &quot;#{@namespace}:experiments:green_button&quot;, experiment(:green_button).send(:key)</diff>
      <filename>test/playground_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>db700f0bd2d80cb7b71ff6ced983cf079f4c6fea</id>
    </parent>
  </parents>
  <author>
    <name>Assaf Arkin</name>
    <email>assaf@labnotes.org</email>
  </author>
  <url>http://github.com/assaf/vanity/commit/99af2d50692c8f5de90496a95c4cdcde53f5f951</url>
  <id>99af2d50692c8f5de90496a95c4cdcde53f5f951</id>
  <committed-date>2009-11-06T18:09:02-08:00</committed-date>
  <authored-date>2009-11-06T18:03:15-08:00</authored-date>
  <message>Separating experiment name &amp; experiment ID.</message>
  <tree>8d75dad7fe322180de75a581f90ffff96fb401f0</tree>
  <committer>
    <name>Assaf Arkin</name>
    <email>assaf@labnotes.org</email>
  </committer>
</commit>
