class DatGretel::Link
Attributes
current[RW]
key[RW]
options[RW]
text[RW]
url[RW]
Public Class Methods
new(key, text, url, options = {})
click to toggle source
# File lib/dat_gretel/link.rb, line 5 def initialize(key, text, url, options = {}) # Use accessors so plugins can override their behavior self.key, self.text, self.url, self.options = key, text, url, options self.current = false end
Public Instance Methods
current!()
click to toggle source
Sets current so current?
will return true
.
# File lib/dat_gretel/link.rb, line 12 def current! @current = true end
current?()
click to toggle source
Returns true
if this is the last link in the breadcrumb trail.
# File lib/dat_gretel/link.rb, line 17 def current? !!@current end
method_missing(method, *args, &block)
click to toggle source
Enables accessors and predicate methods for values in the options
hash. This can be used to pass information to links when rendering breadcrumbs manually.
link = Link.new(:my_crumb, "My Crumb", my_path, title: "Test Title", other_value: "Other") link.title? # => true link.title # => "Test Title" link.other_value? # => true link.other_value # => "Other" link.some_other? # => false link.some_other # => nil
# File lib/dat_gretel/link.rb, line 32 def method_missing(method, *args, &block) if method =~ /(.+)\?$/ options[$1.to_sym].present? else options[method] end end