lib/pupa/models/concerns/linkable.rb in pupa-0.0.9 vs lib/pupa/models/concerns/linkable.rb in pupa-0.0.10
- old
+ new
@@ -7,20 +7,25 @@
included do
attr_accessor :links
dump :links
end
+ def initialize(*args)
+ @links = []
+ super
+ end
+
# Adds a URL.
#
# @param [String] url a URL
# @param [String] note a note, e.g. "Wikipedia page"
def add_link(url, note: nil)
data = {url: url}
if note
data[:note] = note
end
if url
- (@links ||= []) << data
+ @links << data
end
end
end
end
end