Sha256: b54fa100a50ed45b8116306e67528217ed5fa04cbf2c837708513124db0e703d

Contents?: true

Size: 528 Bytes

Versions: 8

Compression:

Stored size: 528 Bytes

Contents

module Pupa
  module Concerns
    # Adds the Popolo `sources` property to a model.
    module Sourceable
      extend ActiveSupport::Concern

      included do
        attr_accessor :sources
      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
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pupa-0.0.8 lib/pupa/models/concerns/sourceable.rb
pupa-0.0.7 lib/pupa/models/concerns/sourceable.rb
pupa-0.0.6 lib/pupa/models/concerns/sourceable.rb
pupa-0.0.5 lib/pupa/models/concerns/sourceable.rb
pupa-0.0.4 lib/pupa/models/concerns/sourceable.rb
pupa-0.0.3 lib/pupa/models/concerns/sourceable.rb
pupa-0.0.2 lib/pupa/models/concerns/sourceable.rb
pupa-0.0.1 lib/pupa/models/concerns/sourceable.rb