Module: Ramenu::ActionController::Utils

Defined in:
lib/ramenu/action_controller.rb

Class Method Summary collapse

Class Method Details

.convert_to_set_of_strings(value, keys) ⇒ Object

This is an horrible method with an 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"]


33
34
35
36
37
38
39
# File 'lib/ramenu/action_controller.rb', line 33

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



14
15
16
17
18
19
20
# File 'lib/ramenu/action_controller.rb', line 14

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