Class: Hash
Overview
:nodoc:
Instance Method Summary collapse
Instance Method Details
#move(from, to) ⇒ Object
27 28 29 30 |
# File 'lib/googl/ruby_extensions.rb', line 27 def move(from, to) self[to] = delete(from) if has_key?(from) self end |
#to_openstruct ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/googl/ruby_extensions.rb', line 31 def to_openstruct map = inject({}) do |mapped, (key, value)| mapped[key.underscore] = value.to_openstruct mapped.move('id', 'label') end OpenStruct.new(map) end |