lib/buoys/link.rb in buoys-0.2.0 vs lib/buoys/link.rb in buoys-0.3.0
- old
+ new
@@ -3,26 +3,27 @@
attr_accessor :text, :options, :options_for_config
attr_reader :current
CONFIG = {
current_class: (Buoys::Config.current_class || 'active'),
- link_current: (Buoys::Config.link_current || false),
+ link_current: (Buoys::Config.link_current || false)
}.with_indifferent_access
def initialize(text, url, options)
@options_for_config, @options = extract_options_and_config(options)
- @text, @_url = text, url
+ @text = text
+ @_url = url
@current = false
end
def mark_as_current!
- options.merge!(class: config[:current_class])
+ options[:class] = config[:current_class]
@current = true
end
def current?
- !!@current
+ @current
end
def url
return '' if current? && !config[:link_current]
@@ -37,11 +38,11 @@
def config
CONFIG.merge(options_for_config)
end
- def extract_options_and_config(_options)
- options = _options.with_indifferent_access
+ def extract_options_and_config(opts)
+ options = opts.with_indifferent_access
config = (options.keys & CONFIG.keys).each_with_object({}) {|key, hash|
hash[key] = options.delete(key)
}
[config, options]