Module: Futures::ClassMethods

Defined in:
lib/futures.rb

Instance Method Summary collapse

Instance Method Details

#future(*attrs) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/futures.rb', line 30

def future(*attrs)
  attrs.each do |attr|
    self.class_eval "
      def #{attr}(timeout = nil)
        @__#{attr}_future ||= Futures::Value.new
        @__#{attr}_future.read(timeout)
      end

      def #{attr}=(val)
        @__#{attr}_future ||= Futures::Value.new
        @__#{attr}_future.write(val)
      end

    "
  end
end