Module: BreadcrumbsOnRails::ActionController::Utils

Defined in:
lib/breadcrumbs_on_rails/action_controller.rb

Class Method Summary collapse

Class Method Details

.convert_to_set_of_strings(value, keys) ⇒ Object

This is a horrible method with a horrible name.

convert_to_set_of_strings(nil, [:foo, :bar])
# => nil
convert_to_set_of_strings(true, [:foo, :bar])
# => ["foo", "bar"]
convert_to_set_of_strings(:foo, [:foo, :bar])
# => ["foo"]
convert_to_set_of_strings([:foo, :bar, :baz], [:foo, :bar])
# => ["foo", "bar", "baz"]

55
56
57
58
59
60
61
# File 'lib/breadcrumbs_on_rails/action_controller.rb', line 55

def self.convert_to_set_of_strings(value, keys)
  if value == true
    keys.map(&:to_s).to_set
  elsif value
    Array(value).map(&:to_s).to_set
  end
end

.instance_proc(string) ⇒ Object


36
37
38
39
40
41
42
# File 'lib/breadcrumbs_on_rails/action_controller.rb', line 36

def self.instance_proc(string)
  if string.kind_of?(String)
    proc { |controller| controller.instance_eval(string) }
  else
    string
  end
end