lib/tap/support/lazy_attributes.rb in bahuvrihi-tap-0.11.0 vs lib/tap/support/lazy_attributes.rb in bahuvrihi-tap-0.11.1
- old
+ new
@@ -27,19 +27,19 @@
lazydoc = Lazydoc[source_file]
lazydoc.resolve if resolve
lazydoc
end
- # Creates a lazy attribute reader for the specified attribute.
+ # Creates a lazy attribute accessor for the specified attribute.
def lazy_attr(key, attribute=key)
- instance_eval %Q{def #{key}; @#{key} ||= get_lazy_attr('#{attribute}'); end}
+ instance_eval %Q{
+ def #{key}
+ lazydoc[to_s]['#{attribute}'] ||= Lazydoc::Comment.new
+ end
+
+ def #{key}=(comment)
+ Lazydoc[source_file][to_s]['#{attribute}'] = comment
+ end}
end
-
- private
-
- def get_lazy_attr(attribute) # :nodoc:
- lazydoc[self.to_s][attribute] ||= Lazydoc::Comment.new
- end
-
end
end
end
\ No newline at end of file