Module: GollyUtils::Singleton::ClassMethods
- Defined in:
- lib/golly-utils/singleton.rb
Instance Method Summary collapse
-
#def_accessor(target, name = nil) ⇒ nil
Creates an instance accessor as
attr_accessordoes, execpt that the default value will be the singleton instance. -
#hide_singleton_methods(*matchers) ⇒ nil
Prevents class-level delegate methods from being created for certain instance methods.
Instance Method Details
#def_accessor(target, name = nil) ⇒ nil
Creates an instance accessor as attr_accessor does, execpt that the default value will be the singleton
instance.
78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/golly-utils/singleton.rb', line 78 def def_accessor(target, name=nil) name ||= __default_singleton_attr_name target.class_eval <<-EOB def #{name} @#{name} ||= ::#{self}.instance end def #{name}=(v) @#{name}= v end EOB nil end |
#hide_singleton_methods(*matchers) ⇒ nil
Prevents class-level delegate methods from being created for certain instance methods.
95 96 97 98 99 100 101 |
# File 'lib/golly-utils/singleton.rb', line 95 def hide_singleton_methods(*matchers) r= __gu_singleton_rejects r.concat matchers r.flatten! r.uniq! nil end |