Module: Waw::FullState::OnClass
- Included in:
- ActionController
- Defined in:
- lib/waw/fullstate/on_class.rb
Overview
Provides the introspection methods for installing fullstate utilities on classes.
Instance Method Summary collapse
-
#__full_state_variables ⇒ Object
Returns the class full state variables.
-
#query_var(name, &block) ⇒ Object
Installs a query variable with a given block.
-
#session_var(name, default_value = nil, &block) ⇒ Object
Installs a friendly session variable on the controller.
Instance Method Details
#__full_state_variables ⇒ Object
Returns the class full state variables
8 9 10 |
# File 'lib/waw/fullstate/on_class.rb', line 8 def __full_state_variables @__full_state_variables ||= {} end |
#query_var(name, &block) ⇒ Object
Installs a query variable with a given block
31 32 33 |
# File 'lib/waw/fullstate/on_class.rb', line 31 def query_var(name, &block) session_var(name, nil, &block) end |
#session_var(name, default_value = nil, &block) ⇒ Object
Installs a friendly session variable on the controller
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/waw/fullstate/on_class.rb', line 13 def session_var(name, default_value=nil, &block) __full_state_variables[name] = Waw::FullState::Variable.new(name, default_value, &block) instance_eval <<-EOF class << self def #{name} __full_state_variables[:#{name}].value(self) end def #{name}=(arg) __full_state_variables[:#{name}].value = arg end def reset(varname) __full_state_variables[varname].reset end end EOF end |