Class: Hash

Inherits:
Object show all
Defined in:
lib/card/core_ext.rb

Class Method Summary collapse

Class Method Details

.new_from_semicolon_attr_list(attr_string) ⇒ Object



57
58
59
60
61
62
63
64
65
66
# File 'lib/card/core_ext.rb', line 57

def new_from_semicolon_attr_list attr_string
  return {} if attr_string.blank?
  attr_string.strip.split(';').inject({}) do |result, pair|
    value, key = pair.split(':').reverse
    key ||= 'view'
    key.strip!; value.strip!
    result[key.to_sym] = value
    result
  end
end