Sha256: 82f64c272c8fd3ed13967eac1353c278910c0f36b0469b8441fba1bcedd26186

Contents?: true

Size: 544 Bytes

Versions: 1

Compression:

Stored size: 544 Bytes

Contents

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

      included do
        attr_accessor :links
        dump :links
      end

      # Adds a URL.
      #
      # @param [String] url a URL
      # @param [String] note a note, e.g. "Wikipedia page"
      def add_link(url, note: nil)
        data = {url: url}
        if note
          data[:note] = note
        end
        if url
          (@links ||= []) << 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/linkable.rb