Class: Module
- Inherits:
-
Object
- Object
- Module
- Defined in:
- lib/inline_acceleration.rb
Instance Method Summary collapse
Instance Method Details
#lazy_attr_reader(name, &block) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/inline_acceleration.rb', line 37 def lazy_attr_reader(name, &block) attr_name = name.to_s.gsub('?', '') define_method("lazy_attr_initialization_#{attr_name}".to_sym, block) class_eval <<-CODE_END def #{name.to_s} @#{attr_name} = lazy_attr_initialization_#{attr_name} if @#{attr_name}.nil? @#{attr_name} end CODE_END end |
#parent_module ⇒ Object
33 34 35 |
# File 'lib/inline_acceleration.rb', line 33 def parent_module self.name.split('::')[0..-2].join('::').to_class end |