lib/parameters/parameters.rb in parameters-0.1.4 vs lib/parameters/parameters.rb in parameters-0.1.5
- old
+ new
@@ -145,22 +145,22 @@
# parameters.
#
def initialize_parameters
self.class.each_param do |param|
# do not override existing instance value if present
- unless instance_variable_get("@#{param.name}")
+ unless instance_variable_get("@#{param.name}".to_sym)
begin
if param.value.kind_of?(Proc)
value = param.value.call()
else
value = param.value.clone
end
rescue TypeError
value = param.value
end
- instance_variable_set("@#{param.name}",value)
+ instance_variable_set("@#{param.name}".to_sym,value)
end
self.params[param.name] = InstanceParam.new(self,param.name,param.description)
end
end
@@ -194,24 +194,24 @@
#
def parameter(name,options={})
name = name.to_sym
# set the instance variable
- instance_variable_set("@#{name}",options[:default])
+ instance_variable_set("@#{name}".to_sym,options[:default])
# add the new parameter
self.params[name] = InstanceParam.new(self,name,options[:description])
instance_eval %{
# define the reader method for the parameter
def #{name}
- instance_variable_get("@#{name}")
+ instance_variable_get("@#{name}".to_sym)
end
# define the writer method for the parameter
def #{name}=(value)
- instance_variable_set("@#{name}",value)
+ instance_variable_set("@#{name}".to_sym,value)
end
}
return params[name]
end
@@ -316,10 +316,10 @@
#
def require_params(*names)
names.each do |name|
name = name.to_s
- unless instance_variable_get("@#{name}")
+ unless instance_variable_get("@#{name}".to_sym)
raise(Parameters::MissingParam,"parameter #{name.dump} has no value",caller)
end
end
return true