lib/gxapi/google_analytics.rb in gxapi_rails-0.0.4 vs lib/gxapi/google_analytics.rb in gxapi_rails-0.0.5

- old
+ new

@@ -4,17 +4,18 @@ class GoogleAnalytics CACHE_KEY = "gxapi-google-analytics-experiments" # - # Gets the experiment that has this name + # Gets the experiment that has this name or ID # - # @param name [String] Name of the experiment + # @param identifier [ExperimentIdentifier] Identifier object for the + # experiment # # @return [Gxapi::Ostruct] - def get_experiment(name) - self.get_experiments.find{|experiment| experiment.name == name} + def get_experiment(identifier) + self.get_experiments.find { |e| identifier.matches_experiment?(e)} end # # return a list of all experiments # @@ -32,15 +33,16 @@ end # # get a variant for an experiment # - # @param experiment_name [String] + # @param identifier [String, Hash] Either the experiment name + # as a String or a hash of what to look for # # @return [Gxapi::Ostruct] - def get_variant(experiment_name) + def get_variant(identifier) # pull in an experiment - experiment = self.get_experiment(experiment_name) + experiment = self.get_experiment(identifier) if self.run_experiment?(experiment) # select variant for the experiment variant = self.select_variant(experiment) # return if it it's present \ No newline at end of file