Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
app/cyclid/monkey_patches.rb

Overview

Add two methods to Hash

Direct Known Subclasses

Cyclid::API::Plugins::BuildHost

Instance Method Summary collapse

Instance Method Details

#%(other) ⇒ Object

Interpolate the data in the ctx hash into any String values



12
13
14
15
16
17
18
19
20
# File 'app/cyclid/monkey_patches.rb', line 12

def %(other)
  hmap do |key, value|
    if value.is_a? String
      { key => value ** other }
    else
      { key => value }
    end
  end
end

#hmapObject



5
6
7
8
9
# File 'app/cyclid/monkey_patches.rb', line 5

def hmap
  inject({}) do |hash, (k, v)|
    hash.merge(yield(k, v))
  end
end