Sha256: 09681083a672bb8dac3784a46ed9158e578be3f5b56dbcdde46a940549737730

Contents?: true

Size: 524 Bytes

Versions: 8

Compression:

Stored size: 524 Bytes

Contents

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

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

8 entries across 8 versions & 1 rubygems

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