Top Level Namespace

Extended by:
Spectre::Delegator

Defined Under Namespace

Modules: Spectre Classes: Array, Hash, NilClass, Object, OpenStruct, String

Instance Method Summary collapse

Methods included from Spectre::Delegator

delegate, redirect

Instance Method Details

#nowObject



137
138
139
# File 'lib/spectre/helpers.rb', line 137

def now
  Time.now
end

#to_recursive_ostruct(hash) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/spectre/environment.rb', line 5

def to_recursive_ostruct(hash)
  OpenStruct.new(
    hash.each_with_object({}) do |(key, val), memo|
      memo[key] = val.is_a?(Hash) ? to_recursive_ostruct(val) : val
    end
  )
end

#uuid(length = nil) ⇒ Object



131
132
133
134
135
# File 'lib/spectre/helpers.rb', line 131

def uuid length = nil
  return SecureRandom.hex(length/2) if length

  SecureRandom.uuid
end