lib/gxapi/controller_methods.rb in gxapi_rails-0.0.4 vs lib/gxapi/controller_methods.rb in gxapi_rails-0.0.5
- old
+ new
@@ -3,25 +3,38 @@
#
# Get the variant and set it as an instance variable, handling
# overriding by passing in the URL
#
- # @param experiment_name [String] Name for the experiment
+ # @param identifier [String, Hash] Name for the experiment or ID hash
+ # for the experiment
# @param ivar_name [String, Symbol] Name for the variable
#
+ # @example
+ #
+ # def my_action
+ # gxapi_get_variant("Name")
+ # end
+ #
+ # # OR
+ #
+ # def my_action
+ # gxapi_get_variant(id: 'id_from_google')
+ # end
+ #
# @return [Celluloid::Future, Gxapi::Ostruct] Variant value
- def gxapi_get_variant(experiment_name, ivar_name = :variant)
+ def gxapi_get_variant(identifier, ivar_name = :variant)
# handle override
if params[ivar_name]
val = Gxapi::Ostruct.new(
value: {
index: -1,
experiment_id: nil,
name: params[ivar_name]
}
)
else
- val = self.gxapi_base.get_variant(experiment_name)
+ val = self.gxapi_base.get_variant(identifier)
end
return instance_variable_set("@#{ivar_name}", val)
end
protected
\ No newline at end of file