Module: ReferenceTracking::ActionController::ActMacro

Defined in:
lib/reference_tracking/action_controller.rb

Instance Method Summary collapse

Instance Method Details

#purge?(action) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/reference_tracking/action_controller.rb', line 45

def purge?(action)
  purges? && purging_options[:actions].include?(action.to_sym)
end

#purges(*actions) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/reference_tracking/action_controller.rb', line 30

def purges(*actions)
  unless purges?
    include ReferenceTracking::ActionController::Purging
    class_inheritable_accessor :purging_options
    self.purging_options = { :header => PURGE_TAGS_HEADER, :actions => [] }
  end

  self.purging_options[:actions] += actions.map(&:to_sym)
  self.purging_options[:actions].uniq
end

#purges?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/reference_tracking/action_controller.rb', line 41

def purges?
  respond_to?(:purging_options)
end

#tracks(*args) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/reference_tracking/action_controller.rb', line 6

def tracks(*args)
  unless tracks_references?
    include ReferenceTracking::ActionController::Tracking

    method = respond_to?(:class_inheritable_accessor) ? :class_inheritable_accessor : :class_attribute
    send(method, :reference_tracking_options)

    self.reference_tracking_options = { :header => TAGS_HEADER }
  end

  options = args.extract_options!
  actions = Array(options.delete(:only) || [:index, :show]) - Array(options.delete(:except))
  args << options unless options.empty?

  actions.map(&:to_sym).each do |action|
    self.reference_tracking_options[action] ||= []
    self.reference_tracking_options[action] += args
  end
end

#tracks_references?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/reference_tracking/action_controller.rb', line 26

def tracks_references?
  respond_to?(:reference_tracking_options) && reference_tracking_options.present?
end