Class: Symbolink::Configuration
- Inherits:
-
Object
- Object
- Symbolink::Configuration
- Defined in:
- lib/symbolink/configuration.rb
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
-
#symbols ⇒ Object
readonly
Returns the value of attribute symbols.
Instance Method Summary collapse
-
#action(sym, ops = {}) ⇒ Object
Define action for symbol Options:.
- #add_icons(map = {}) ⇒ Object (also: #add_icon, #icon)
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
6 7 8 9 10 |
# File 'lib/symbolink/configuration.rb', line 6 def initialize @symbols, @actions = {}, {} @symbols.default_proc = ->(hash, key) { raise ArgumentError, "Unregistered symbolink #{key}" } init_defaults end |
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
4 5 6 |
# File 'lib/symbolink/configuration.rb', line 4 def actions @actions end |
#symbols ⇒ Object (readonly)
Returns the value of attribute symbols.
3 4 5 |
# File 'lib/symbolink/configuration.rb', line 3 def symbols @symbols end |
Instance Method Details
#action(sym, ops = {}) ⇒ Object
Define action for symbol Options:
-
icon: symbol for defined icon or string.
defies new icon with action name as a key if string given as icon uses action sysmbol as icon symbol if not provided
-
title: string to be used as link title
humanized action sysmbol will be used as a title if not provided
-
confirm: string to be used as action confirmation text
data-confirm attribute will be added into the generated link if defined.
31 32 33 34 35 36 37 38 39 |
# File 'lib/symbolink/configuration.rb', line 31 def action(sym, ops = {}) ops[:icon] ||= sym ops[:title] ||= sym.to_s.humanize if ops[:icon].is_a?(String) add_icon sym => ops[:icon] ops[:icon] = sym end @actions[sym] = ops end |
#add_icons(map = {}) ⇒ Object Also known as: add_icon, icon
12 13 14 |
# File 'lib/symbolink/configuration.rb', line 12 def add_icons(map = {}) map.each { |symbol, icon| @symbols[symbol] = icon.html_safe } end |