Module: Symbolink::SymbolinkHelpers
- 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
8 9 10 |
# File 'lib/symbolink/helper.rb', line 8 def symbol(sym) symbolicon(sym) end |
#symbolicon(sym) ⇒ Object
3 4 5 |
# File 'lib/symbolink/helper.rb', line 3 def symbolicon(sym) Symbolink.configuration.symbols[sym] end |
#symbolink_destroy(options = {}, html_options = {}) ⇒ Object
35 36 37 38 |
# File 'lib/symbolink/helper.rb', line 35 def symbolink_destroy( = {}, = {}) [:method] = :delete symbolink_to(:delete, , ) end |
#symbolink_to(sym, options = {}, html_options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/symbolink/helper.rb', line 12 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 |