Module: Pupa::Concerns::Sourceable
- Extended by:
- ActiveSupport::Concern
- Included in:
- Area, Membership, Motion, Organization, Person, Post, Vote, VoteEvent
- Defined in:
- lib/pupa/models/concerns/sourceable.rb
Overview
Adds the Popolo sources
property to a model.
Instance Method Summary collapse
-
#add_source(url, note: nil) ⇒ Object
Adds a source to the object.
- #initialize(*args) ⇒ Object
-
#sources=(sources) ⇒ Object
Sets the sources.
Instance Method Details
#add_source(url, note: nil) ⇒ Object
Adds a source to the object.
28 29 30 31 32 33 34 35 36 |
# File 'lib/pupa/models/concerns/sourceable.rb', line 28 def add_source(url, note: nil) data = {url: url} if note data[:note] = note end if url.present? @sources << data end end |
#initialize(*args) ⇒ Object
12 13 14 15 |
# File 'lib/pupa/models/concerns/sourceable.rb', line 12 def initialize(*args) @sources = [] super end |
#sources=(sources) ⇒ Object
Sets the sources.
20 21 22 |
# File 'lib/pupa/models/concerns/sourceable.rb', line 20 def sources=(sources) @sources = symbolize_keys(sources) end |