module Pupa::Concerns::Linkable
Adds the Popolo ‘links` property to a model.
Attributes
links[R]
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/pupa/models/concerns/linkable.rb, line 12 def initialize(*args) @links = [] super end
Public Instance Methods
add_link(url, note: nil)
click to toggle source
Adds a URL.
@param [String] url a URL @param [String] note a note, e.g. “Wikipedia page”
# File lib/pupa/models/concerns/linkable.rb, line 28 def add_link(url, note: nil) data = {url: url} if note data[:note] = note end if url.present? @links << data end end
links=(links)
click to toggle source
Sets the links.
@param [Array] links a list of links
# File lib/pupa/models/concerns/linkable.rb, line 20 def links=(links) @links = symbolize_keys(links) end