Module: FatFreeCRM::Callback::Helper
- Defined in:
- lib/fat_free_crm/callback.rb
Overview
This makes it possible to call hook() without FatFreeCRM::Callback prefix.
Returns stringified data when called from within templates, and the actual
data otherwise.
Instance Method Summary
collapse
Instance Method Details
#hook(method, caller, context = {}, &block) ⇒ Object
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
# File 'lib/fat_free_crm/callback.rb', line 110
def hook(method, caller, context = {}, &block)
if caller.is_a?(ActionView::Base)
hooks = FatFreeCRM::Callback.view_hook(method, caller, context)
view_data = "".html_safe
hooks[:before].each { |data| view_data << data }
if hooks[:replace].empty?
view_data << if block_given?
capture(&block)
else
FatFreeCRM::Callback.hook(method, caller, context)
end
else
hooks[:replace].each { |data| view_data << data }
end
hooks[:after].each { |data| view_data << data }
view_data
else
FatFreeCRM::Callback.hook(method, caller, context)
end
end
|