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

Instance Method Details

#add_source(url, note: nil) ⇒ Object

Adds a source to the object.

Parameters:

  • url (String)

    a URL

  • note (String) (defaults to: nil)

    a note



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.

Parameters:

  • sources (Array)

    a list of sources



20
21
22
# File 'lib/pupa/models/concerns/sourceable.rb', line 20

def sources=(sources)
  @sources = symbolize_keys(sources)
end