Sha256: 88855fca5f0afe1c043a6aba8d30e65af8dd7ca375d90d5274c124619c417c2c
Contents?: true
Size: 1.06 KB
Versions: 2
Compression:
Stored size: 1.06 KB
Contents
module Buoys class Link 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), }.with_indifferent_access def initialize(text, url, options) @options_for_config, @options = extract_options_and_config(options) @text, @_url = text, url @current = false end def mark_as_current! options.merge!(class: config[:current_class]) @current = true end def current? !!@current end def url return '' if current? && !config[:link_current] @_url || '' end def url=(str) @_url = str end private def config CONFIG.merge(options_for_config) end def extract_options_and_config(_options) options = _options.with_indifferent_access config = (options.keys & CONFIG.keys).each_with_object({}) {|key, hash| hash[key] = options.delete(key) } [config, options] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
buoys-0.2.0 | lib/buoys/link.rb |
buoys-0.1.0 | lib/buoys/link.rb |