Module: Symbolink::SymbolinkHelpers
- Includes:
- ActionView::Helpers::UrlHelper
- Defined in:
- lib/symbolink/helper.rb
Instance Method Summary collapse
- #symbol(sym) ⇒ Object
- #symbolicon(sym) ⇒ Object
- #symbolink_destroy(options = {}, html_options = {}) ⇒ Object
- #symbolink_to(sym, options = {}, html_options = {}) ⇒ Object
Instance Method Details
#symbol(sym) ⇒ Object
9 10 11 |
# File 'lib/symbolink/helper.rb', line 9 def symbol(sym) symbolicon(sym) end |
#symbolicon(sym) ⇒ Object
4 5 6 |
# File 'lib/symbolink/helper.rb', line 4 def symbolicon(sym) Symbolink.configuration.symbols[sym] end |
#symbolink_destroy(options = {}, html_options = {}) ⇒ Object
36 37 38 39 |
# File 'lib/symbolink/helper.rb', line 36 def symbolink_destroy( = {}, = {}) [:method] = :delete symbolink_to(:delete, , ) end |
#symbolink_to(sym, options = {}, html_options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/symbolink/helper.rb', line 13 def symbolink_to(sym, = {}, = {}) action = Symbolink.configuration.actions[sym] if action icon = action[:icon] title = action[:title] confirm = action[:confirm] else icon = sym title = sym.to_s.humanize confirm = nil end [:title] ||= title if confirm [:data] ||= {} %w{confirm data-confirm}.map(&:to_sym).select{ |opt| [opt] }.each do |opt| [:data][:confirm] = [opt] .delete(opt) end [:data][:confirm] ||= confirm end link_to(symbolicon(icon), , ) end |