Class: ActiveScaffold::Config::Base::UserSettings

Inherits:
Object
  • Object
show all
Defined in:
lib/active_scaffold/config/base.rb

Instance Method Summary collapse

Constructor Details

#initialize(conf, storage, params, action = :base) ⇒ UserSettings

Returns a new instance of UserSettings



46
47
48
49
50
51
52
53
54
# File 'lib/active_scaffold/config/base.rb', line 46

def initialize(conf, storage, params, action = :base)
  # the session hash relevant to this action
  @session = storage
  # all the request params
  @params = params
  # the configuration object for this action
  @conf = conf
  @action = action
end

Instance Method Details

#[](key) ⇒ Object



56
57
58
# File 'lib/active_scaffold/config/base.rb', line 56

def [](key)
  @session[@action][key] if @action && @session[@action]
end

#[]=(key, value) ⇒ Object



60
61
62
63
64
65
66
67
68
# File 'lib/active_scaffold/config/base.rb', line 60

def []=(key, value)
  @session[@action] ||= {}
  if value
    @session[@action][key] = value
  else
    @session[@action].delete key
    @session.delete @action if @session[@action].empty?
  end
end