Module: Caracal::Core::Ignorables

Included in:
Document
Defined in:
lib/caracal/core/ignorables.rb

Overview

This module encapsulates all the functionality related to registering and retrieving ignorable namespaces.

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/caracal/core/ignorables.rb', line 8

def self.included(base)
  base.class_eval do

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

    #============== ATTRIBUTES ==========================

    def ignorable(prefix)
      register_ignorable(prefix)
    end


    #============== GETTERS =============================

    def ignorables
      @ignorables ||= []
    end


    #============== REGISTRATION ========================

    def register_ignorable(prefix)
      unless ignorables.include?(prefix)
        ignorables << prefix
        prefix
      end
    end

    def unregister_ignorable(prefix)
      ignorables.delete(prefix)
    end

  end
end