Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix overwriting lambda with evaluated value #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions lib/crummy/action_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,20 @@ def add_crumb(name, *args)
end
end

# Get the return value of the name if its a proc.
name = name.call(instance) if name.is_a?(Proc)
if name.is_a?(Proc)
instance.add_crumb(name.call(instance), url, options)
return
end

_record = instance.instance_variable_get("@#{name}") unless name.kind_of?(String)
if _record and _record.respond_to? :to_param
instance.add_crumb(_record.to_s, url || instance.url_for(_record), options)
else
instance.add_crumb(name, url, options)
unless name.kind_of?(String)
_record = instance.instance_variable_get("@#{name}")
if _record and _record.respond_to? :to_param
instance.add_crumb(_record.to_s, url || instance.url_for(_record), options)
return
end
end


instance.add_crumb(name, url, options)
# FIXME: url = instance.url_for(name) if name.respond_to?("to_param") && url.nil?
# FIXME: Add ||= for the name, url above
end
Expand Down