Class: Breadcrumb::Trail

Inherits:
Struct
  • Object
show all
Defined in:
lib/breadcrumb.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#actionObject

Returns the value of attribute action

Returns:

  • (Object)

    the current value of action



5
6
7
# File 'lib/breadcrumb.rb', line 5

def action
  @action
end

#controllerObject

Returns the value of attribute controller

Returns:

  • (Object)

    the current value of controller



5
6
7
# File 'lib/breadcrumb.rb', line 5

def controller
  @controller
end

#lineObject

Returns the value of attribute line

Returns:

  • (Object)

    the current value of line



5
6
7
# File 'lib/breadcrumb.rb', line 5

def line
  @line
end

#optionsObject

Returns the value of attribute options

Returns:

  • (Object)

    the current value of options



5
6
7
# File 'lib/breadcrumb.rb', line 5

def options
  @options
end

#trailObject

Returns the value of attribute trail

Returns:

  • (Object)

    the current value of trail



5
6
7
# File 'lib/breadcrumb.rb', line 5

def trail
  @trail
end

Instance Method Details

#condition_met?(obj) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
10
11
12
13
14
# File 'lib/breadcrumb.rb', line 6

def condition_met?(obj)
  if options[:if]
    evaluate(obj, options[:if])
  elsif options[:unless]
    !evaluate(obj, options[:unless])
  else
    true
  end
end

#evaluate(obj, condition) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/breadcrumb.rb', line 16

def evaluate(obj, condition)
  if condition.respond_to?(:call)
    condition.call(obj.controller)
  else
    obj.send(condition)
  end
end