Module: Rux::Utils

Extended by:
Utils
Included in:
Utils
Defined in:
lib/rux/utils.rb

Instance Method Summary collapse

Instance Method Details

#attr_to_hash_elem(key, value, slugify: true) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/rux/utils.rb', line 3

def attr_to_hash_elem(key, value, slugify: true)
  key = key.gsub('-', '_') if slugify

  if key =~ /\A[\w\d]+\z/
    "#{key}: #{value}"
  else
    ":\"#{key}\" => #{value}"
  end
end