Sha256: 79654ec6640aff747c541306339241ef84bc20fd5e9eab852debad4aa233b922
Contents?: true
Size: 791 Bytes
Versions: 5
Compression:
Stored size: 791 Bytes
Contents
require 'tap/support/lazydoc' module Tap module Support module LazyAttributes # The source_file for self. Must be set independently. attr_accessor :source_file # Returns the lazydoc for source_file def lazydoc(resolve=true) lazydoc = Lazydoc[source_file] lazydoc.resolve if resolve lazydoc end # Creates a lazy attribute reader for the specified attribute. def lazy_attr(key, attribute=key) instance_eval %Q{def #{key}; @#{key} ||= get_lazy_attr('#{attribute}'); end} end private def get_lazy_attr(attribute) lazydoc[self.to_s][attribute] || (lazydoc.attributes(self.to_s)[attribute] = Tap::Support::Comment.new) end end end end
Version data entries
5 entries across 5 versions & 2 rubygems