Class: FatFreeCRM::Callback::Base

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/fat_free_crm/callback.rb

Overview


Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.view_hooksObject

Returns the value of attribute view_hooks.



80
81
82
# File 'lib/fat_free_crm/callback.rb', line 80

def view_hooks
  @view_hooks
end

Class Method Details

.add_view_hook(hook, proc, position) ⇒ Object



82
83
84
85
# File 'lib/fat_free_crm/callback.rb', line 82

def add_view_hook(hook, proc, position)
  @view_hooks[hook] += [{ proc: proc,
                          position: position }]
end

.inherited(child) ⇒ Object



70
71
72
73
74
75
76
77
# File 'lib/fat_free_crm/callback.rb', line 70

def self.inherited(child)
  FatFreeCRM::Callback.add(child)
  # Positioning hash to determine where content is placed.
  child.class_eval do
    @view_hooks = Hash.new([])
  end
  super
end

.insert_after(hook, &block) ⇒ Object



91
92
93
# File 'lib/fat_free_crm/callback.rb', line 91

def insert_after(hook, &block)
  add_view_hook(hook, block,        :after)
end

.insert_before(hook, &block) ⇒ Object



87
88
89
# File 'lib/fat_free_crm/callback.rb', line 87

def insert_before(hook, &block)
  add_view_hook(hook, block,        :before)
end

.remove(hook) ⇒ Object



99
100
101
# File 'lib/fat_free_crm/callback.rb', line 99

def remove(hook)
  add_view_hook(hook, proc { "" }, :replace)
end

.replace(hook, &block) ⇒ Object



95
96
97
# File 'lib/fat_free_crm/callback.rb', line 95

def replace(hook, &block)
  add_view_hook(hook, block,        :replace)
end