Module: HasBreadcrumb::ClassMethods

Defined in:
lib/has_breadcrumb/has_breadcrumb.rb

Instance Method Summary collapse

Instance Method Details

#has_breadcrumb(options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/has_breadcrumb/has_breadcrumb.rb', line 3

def has_breadcrumb options = {}
  define_method :breadcrumb_parent do
    return nil if options[:parent].nil?
    self.send(options[:parent])
  end

  define_method :breadcrumb_name do
    return "" if options[:title].nil?
    case options[:title].class.name
      when "Symbol"
        self.send(options[:title])
      else
        options[:title]
    end
  end
end