Module: Card::Env::Support

Included in:
Card::Env
Defined in:
lib/card/env/support.rb

Overview

utility methods for Card::Env

Instance Method Summary collapse

Instance Method Details

#hash(hashish) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/card/env/support.rb', line 13

def hash hashish
  case hashish
  when Hash then hashish.clone
  when ActionController::Parameters then hashish.to_unsafe_h
  else {}
  end
end

#reset_sessionObject



21
22
23
24
25
26
27
# File 'lib/card/env/support.rb', line 21

def reset_session
  if session.is_a? Hash
    @session = {}
  else
    controller&.reset_session
  end
end

#with_params(hash) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/card/env/support.rb', line 5

def with_params hash
  old_params = params.clone
  params.merge! hash
  yield
ensure
  @params = old_params
end