lib/pupa/models/concerns/sourceable.rb in pupa-0.0.9 vs lib/pupa/models/concerns/sourceable.rb in pupa-0.0.10
- old
+ new
@@ -7,20 +7,25 @@
included do
attr_accessor :sources
dump :sources
end
+ def initialize(*args)
+ @sources = []
+ super
+ end
+
# Adds a source to the object.
#
# @param [String] url a URL
# @param [String] note a note
def add_source(url, note: nil)
data = {url: url}
if note
data[:note] = note
end
if url
- (@sources ||= []) << data
+ @sources << data
end
end
end
end
end