Module: Concurrent::Synchronization::Volatile::ClassMethods

Defined in:
lib/concurrent-ruby/concurrent/synchronization/volatile.rb

Instance Method Summary collapse

Instance Method Details

#attr_volatile(*names) ⇒ undocumented



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/concurrent-ruby/concurrent/synchronization/volatile.rb', line 39

def attr_volatile(*names)
  names.each do |name|
    ivar = :"@volatile_#{name}"
    class_eval <<-RUBY, __FILE__, __LINE__ + 1
      def #{name}
        #{ivar}
      end

      def #{name}=(value)
        #{ivar} = value
      end
    RUBY
  end
  names.map { |n| [n, :"#{n}="] }.flatten
end