Sha256: 627e7d9e9aa991c5a70a72b38e5349c682e423a70022a4b22dfb0e75fb2b01f4

Contents?: true

Size: 616 Bytes

Versions: 1

Compression:

Stored size: 616 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

      def initialize(*args)
        @sources = []
        super
      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.10 lib/pupa/models/concerns/sourceable.rb