Module: Que::Web::Helpers
- Defined in:
- lib/que/web.rb
Instance Method Summary collapse
- #active_class(pattern) ⇒ Object
- #flash ⇒ Object
- #format_args(job) ⇒ Object
- #format_error(job) ⇒ Object
- #link_to(path) ⇒ Object
- #path_with_search(path) ⇒ Object
- #relative_time(time) ⇒ Object
- #root_path ⇒ Object
- #set_flash(level, val) ⇒ Object
- #truncate(str, len = 200) ⇒ Object
Instance Method Details
#active_class(pattern) ⇒ Object
174 175 176 177 178 |
# File 'lib/que/web.rb', line 174 def active_class(pattern) if request.path.match pattern "active" end end |
#flash ⇒ Object
202 203 204 205 |
# File 'lib/que/web.rb', line 202 def flash @sweep_flash = true session[FLASH_KEY] ||= {} end |
#format_args(job) ⇒ Object
180 181 182 |
# File 'lib/que/web.rb', line 180 def format_args(job) truncate job.args.map(&:inspect).join(', ') end |
#format_error(job) ⇒ Object
184 185 186 187 188 |
# File 'lib/que/web.rb', line 184 def format_error(job) return unless job.last_error line = job.last_error.lines.first || '' truncate line, 30 end |
#link_to(path) ⇒ Object
165 166 167 |
# File 'lib/que/web.rb', line 165 def link_to(path) to path_with_search(path) end |
#path_with_search(path) ⇒ Object
169 170 171 172 |
# File 'lib/que/web.rb', line 169 def path_with_search(path) path += "?search=#{search_param}" if search_param.present? path end |
#relative_time(time) ⇒ Object
190 191 192 |
# File 'lib/que/web.rb', line 190 def relative_time(time) %{<time class="timeago" datetime="#{time.utc.iso8601}">#{time.utc}</time>} end |
#root_path ⇒ Object
161 162 163 |
# File 'lib/que/web.rb', line 161 def root_path "#{env['SCRIPT_NAME']}/" end |
#set_flash(level, val) ⇒ Object
207 208 209 210 |
# File 'lib/que/web.rb', line 207 def set_flash(level, val) hash = session[FLASH_KEY] ||= {} hash[level] = val end |
#truncate(str, len = 200) ⇒ Object
194 195 196 197 198 199 200 |
# File 'lib/que/web.rb', line 194 def truncate(str, len=200) if str.length > len str[0..len] + '...' else str end end |