Sha256: 59ee6a33500f14c3db88f5081989313a316f046cb038f0d1a2bc1ae1ee82f6a1

Contents?: true

Size: 1.43 KB

Versions: 9

Compression:

Stored size: 1.43 KB

Contents

require 'caracal/core/models/bookmark_model'
require 'caracal/errors'


module Caracal
  module Core

    # This module encapsulates all the functionality related to adding
    # bookmarks to the document.
    #
    module Bookmarks
      def self.included(base)
        base.class_eval do

          #------------------------------------------------
          # Public Methods
          #------------------------------------------------

          #========== BOOKMARKS ===========================

          def bookmark_start(*args, &block)
            options = Caracal::Utilities.extract_options!(args)
            options.merge!({ start: true})

            model = Caracal::Core::Models::BookmarkModel.new(options, &block)
            if model.valid?
              contents << model
            else
              raise Caracal::Errors::InvalidModelError, 'Bookmark starting tags require an id and a name.'
            end
            model
          end

          def bookmark_end(*args, &block)
            options = Caracal::Utilities.extract_options!(args)
            options.merge!({ start: false})

            model = Caracal::Core::Models::BookmarkModel.new(options, &block)
            if model.valid?
              contents << model
            else
              raise Caracal::Errors::InvalidModelError, 'Bookmark ending tags require an id.'
            end
            model
          end
          
        end
      end
    end

  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
caracal_the_curve-1.4.6 lib/caracal/core/bookmarks.rb
caracal_the_curve-1.4.5 lib/caracal/core/bookmarks.rb
caracal_the_curve-1.4.4 lib/caracal/core/bookmarks.rb
caracal_the_curve-1.4.3 lib/caracal/core/bookmarks.rb
caracal_the_curve-1.4.2 lib/caracal/core/bookmarks.rb
caracal_the_curve-1.4.1 lib/caracal/core/bookmarks.rb
caracal-1.4.1 lib/caracal/core/bookmarks.rb
caracal-1.4.0 lib/caracal/core/bookmarks.rb
caracal-1.3.0 lib/caracal/core/bookmarks.rb