Sha256: 280e993980e4f52478c252c17f769e4975d3d6d910180017239f9bebf86bb919

Contents?: true

Size: 401 Bytes

Versions: 1

Compression:

Stored size: 401 Bytes

Contents

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

      define_method(name) do
        ivar = instance_variable_get name_ivar
        instance_variable_set name_ivar, 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

1 entries across 1 versions & 1 rubygems

Version Path
tori-0.0.4 lib/tori/define.rb