Sha256: 1dbccda3e634b0506a58ff72bf7af1c1bb9a29343d695762bdb4d058726773c1

Contents?: true

Size: 477 Bytes

Versions: 12

Compression:

Stored size: 477 Bytes

Contents

module Tori
  module Define
    def tori(name, to: nil, &block)
      name_ivar = "@#{name}".to_sym

      define_method(name) do
        ivar = instance_variable_get name_ivar
        ivar || instance_variable_set(name_ivar, File.new(self, title: name, to: to, &block))
      end

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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
tori-0.8.0 lib/tori/define.rb
tori-0.7.2 lib/tori/define.rb
tori-0.7.1 lib/tori/define.rb
tori-0.7.0 lib/tori/define.rb
tori-0.6.6 lib/tori/define.rb
tori-0.6.5 lib/tori/define.rb
tori-0.6.4 lib/tori/define.rb
tori-0.6.3 lib/tori/define.rb
tori-0.6.2 lib/tori/define.rb
tori-0.6.1 lib/tori/define.rb
tori-0.6.0 lib/tori/define.rb
tori-0.5.0 lib/tori/define.rb