Class: Module

Inherits:
Object
  • Object
show all
Defined in:
lib/cinch/rubyext/module.rb

Overview

Extensions to Ruby’s Module class.

Instance Method Summary collapse

Instance Method Details

#synced_attr_accessor(attr) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Like ‘attr_accessor`, but for defining a synchronized attribute accessor



24
25
26
27
# File 'lib/cinch/rubyext/module.rb', line 24

def synced_attr_accessor(attr)
  synced_attr_reader(attr)
  attr_accessor(attr)
end

#synced_attr_reader(attribute) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Like ‘attr_reader`, but for defining a synchronized attribute reader.



9
10
11
12
13
14
15
16
17
18
# File 'lib/cinch/rubyext/module.rb', line 9

def synced_attr_reader(attribute)
  undef_method(attribute)
  define_method(attribute) do
    attr(attribute)
  end

  define_method("#{attribute}_unsynced") do
    attr(attribute, false, true)
  end
end