Module: OsCtld::Lockable::ClassMethods

Defined in:
lib/osctld/lockable.rb

Instance Method Summary collapse

Instance Method Details

#attr_exclusive_writer(*attrs) ⇒ Object



230
231
232
233
234
235
236
# File 'lib/osctld/lockable.rb', line 230

def attr_exclusive_writer(*attrs)
  attrs.each do |attr|
    define_method(:"#{attr}=") do |v|
      exclusively { instance_variable_set("@#{attr}", v) }
    end
  end
end

#attr_inclusive_reader(*attrs) ⇒ Object



222
223
224
225
226
227
228
# File 'lib/osctld/lockable.rb', line 222

def attr_inclusive_reader(*attrs)
  attrs.each do |attr|
    define_method(attr) do
      inclusively { instance_variable_get("@#{attr}") }
    end
  end
end

#attr_synchronized_accessor(*attrs) ⇒ Object



238
239
240
241
# File 'lib/osctld/lockable.rb', line 238

def attr_synchronized_accessor(*attrs)
  attr_inclusive_reader(*attrs)
  attr_exclusive_writer(*attrs)
end