Class: FatFreeCRM::Callback::Base
- Inherits:
-
Object
- Object
- FatFreeCRM::Callback::Base
- Includes:
- Singleton
- Defined in:
- lib/fat_free_crm/callback.rb
Overview
Class Attribute Summary collapse
-
.view_hooks ⇒ Object
Returns the value of attribute view_hooks.
Class Method Summary collapse
- .add_view_hook(hook, proc, position) ⇒ Object
- .inherited(child) ⇒ Object
- .insert_after(hook, &block) ⇒ Object
- .insert_before(hook, &block) ⇒ Object
- .remove(hook) ⇒ Object
- .replace(hook, &block) ⇒ Object
Class Attribute Details
.view_hooks ⇒ Object
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 |