Module: Card::Env

Extended by:
LocationHistory, Serializable, Serialization, SlotOptions, Support
Defined in:
lib/card/env.rb,
lib/card/env/success.rb,
lib/card/env/support.rb,
lib/card/env/location.rb,
lib/card/env/serializable.rb,
lib/card/env/slot_options.rb,
lib/card/env/serialization.rb,
lib/card/env/success/target.rb,
lib/card/env/location_history.rb

Overview

Card::Env is a module for containing the variable details of the environment in which Card operates.

Env can differ for each request; Card.config should not.

Defined Under Namespace

Modules: Location, LocationHistory, Serializable, Serialization, SlotOptions, Support Classes: Success

Class Attribute Summary collapse

Attributes included from Serializable

#main_name, #params

Class Method Summary collapse

Methods included from LocationHistory

discard_locations_for, interrupted_action, location_history, previous_location, save_interrupted_action, save_location, save_location?, url_key_for_location

Methods included from SlotOptions

slot_opts

Methods included from Support

hash, reset_session, with_params

Methods included from Serializable

ajax, host, html, ip, origin, protocol

Methods included from Serialization

serialize, with

Class Attribute Details

.controllerObject

Returns the value of attribute controller.



14
15
16
# File 'lib/card/env.rb', line 14

def controller
  @controller
end

.main_name=(value) ⇒ Object (writeonly)

Sets the attribute main_name

Parameters:

  • value

    the value to set the attribute main_name to.



15
16
17
# File 'lib/card/env.rb', line 15

def main_name=(value)
  @main_name = value
end

.params=(value) ⇒ Object (writeonly)

Sets the attribute params

Parameters:

  • value

    the value to set the attribute params to.



15
16
17
# File 'lib/card/env.rb', line 15

def params=(value)
  @params = value
end

.sessionObject



21
22
23
# File 'lib/card/env.rb', line 21

def session
  @session ||= request&.session || {}
end

Class Method Details

.localhost?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/card/env.rb', line 35

def localhost?
  host&.match?(/^localhost/)
end

.requestObject



17
18
19
# File 'lib/card/env.rb', line 17

def request
  controller&.request
end

.reset(controller = nil) ⇒ Object



25
26
27
28
29
# File 'lib/card/env.rb', line 25

def reset controller=nil
  @controller = controller
  @params = controller&.params || {}
  @session = @success = @serialized = @slot_opts = nil
end

.success(cardname = nil) ⇒ Object



31
32
33
# File 'lib/card/env.rb', line 31

def success cardname=nil
  @success ||= Env::Success.new(cardname, params[:success])
end