Module: TrustyCms::Taggable

Included in:
DeprecatedTags, Page, SnippetTags, StandardTags
Defined in:
lib/trusty_cms/taggable.rb

Defined Under Namespace

Modules: ClassMethods, Util

Constant Summary collapse

@@tag_descriptions =
{}
@@tag_deprecations =
{}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



6
7
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
# File 'lib/trusty_cms/taggable.rb', line 6

def self.included(base)
  base.extend(ClassMethods)
  base.module_eval do
    def self.included(new_base)
      super
      new_base.class_eval do
        include Rails.application.routes.url_helpers
      end
      class << new_base
        def default_url_options
          { controller: 'site', action: 'show_page', only_path: true }
        end
      end
      new_base.tag_descriptions.merge! tag_descriptions
    end

    protected

    def params
      @params ||= request.parameters unless request.nil?
    end

    def request_uri
      @request_url ||= request.request_uri unless request.nil?
    end
  end
end

Instance Method Details

#render_tag(name, tag_binding) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/trusty_cms/taggable.rb', line 34

def render_tag(name, tag_binding)
  tag_method_name = "tag:#{name}"
  tag_method = method(tag_method_name)
  if tag_method.arity == 0
    tag_method.call
  else
    tag_method.call tag_binding
  end
end

#tag_descriptions(hash = nil) ⇒ Object



48
49
50
# File 'lib/trusty_cms/taggable.rb', line 48

def tag_descriptions(hash = nil)
  self.class.tag_descriptions hash
end

#tagsObject



44
45
46
# File 'lib/trusty_cms/taggable.rb', line 44

def tags
  Util.tags_in_array(methods)
end

#warn_of_tag_deprecation(tag_name, options = {}) ⇒ Object



52
53
54
55
56
57
# File 'lib/trusty_cms/taggable.rb', line 52

def warn_of_tag_deprecation(tag_name, options = {})
  message = "Deprecated radius tag <r:#{tag_name}>"
  message << " will be removed or significantly changed in trusty #{options[:deadline]}." if options[:deadline]
  message << " Please use <r:#{options[:substitute]}> instead." if options[:substitute]
  ActiveSupport::Deprecation.warn(message)
end