Sha256: 956efec65c33e861defad43ca765a7ede9d0c71be897298de5012fd7f6dd4bcb

Contents?: true

Size: 402 Bytes

Versions: 4

Compression:

Stored size: 402 Bytes

Contents

module Tori
  module Define
    def tori(name)
      name_ivar = "@#{name}".to_sym

      define_method(name) do
        ivar = instance_variable_get name_ivar
        ivar || instance_variable_set(name_ivar, File.new(self))
      end

      define_method("#{name}=") do |uploader|
        file = File.new(self, from: uploader)
        instance_variable_set name_ivar, file
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tori-0.0.8 lib/tori/define.rb
tori-0.0.7 lib/tori/define.rb
tori-0.0.6 lib/tori/define.rb
tori-0.0.5 lib/tori/define.rb