Sha256: 2c218d1d03fb90bc4a033008c3a25eab819b28c359a80df6fd1cf5d1331b535b

Contents?: true

Size: 550 Bytes

Versions: 1

Compression:

Stored size: 550 Bytes

Contents

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

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

1 entries across 1 versions & 1 rubygems

Version Path
pupa-0.0.9 lib/pupa/models/concerns/sourceable.rb