lib/tori/define.rb in tori-0.0.2 vs lib/tori/define.rb in tori-0.0.3
- old
+ new
@@ -1,21 +1,17 @@
module Tori
module Define
def tori(name)
- name_hash_get = "#{name}_hash".to_sym
- name_ivar = "@#{name}".to_sym
- name_hash_ivar = "@#{name}_hash".to_sym
+ name_file_ivar = "@#{name}_file".to_sym
define_method(name) do
- instance_variable_get name_ivar
+ ivar = instance_variable_get name_file_ivar
+ instance_variable_set name_file_ivar, ivar || File.new(self)
end
define_method("#{name}=") do |uploader|
- instance_variable_set name_ivar, uploader
- end
-
- define_method(name_hash_get) do
- Tori.config.filename_callback.call(self)
+ file = File.new(self, uploader)
+ instance_variable_set name_file_ivar, file
end
end
end
end