Class: SimpleCrud::ActionContext
- Inherits:
-
Object
- Object
- SimpleCrud::ActionContext
- Defined in:
- lib/simple_crud/action_context.rb
Direct Known Subclasses
EditContext, IndexContext, NewContext, PersistenceContext, ShowContext
Constant Summary collapse
- DEFAULT_CACHE_TTL =
300
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(controller, klass, parameters, &block) ⇒ ActionContext
constructor
A new instance of ActionContext.
Constructor Details
#initialize(controller, klass, parameters, &block) ⇒ ActionContext
Returns a new instance of ActionContext.
13 14 15 16 17 18 |
# File 'lib/simple_crud/action_context.rb', line 13 def initialize(controller, klass, parameters, &block) @controller = controller @klass = klass @parameters = parameters @block = block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
7 8 9 |
# File 'lib/simple_crud/action_context.rb', line 7 def block @block end |
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
7 8 9 |
# File 'lib/simple_crud/action_context.rb', line 7 def controller @controller end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
7 8 9 |
# File 'lib/simple_crud/action_context.rb', line 7 def klass @klass end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
7 8 9 |
# File 'lib/simple_crud/action_context.rb', line 7 def parameters @parameters end |
Class Method Details
.cache_key_for(model, action, path) ⇒ Object
9 10 11 |
# File 'lib/simple_crud/action_context.rb', line 9 def self.cache_key_for(model, action, path) "#{model.model_name.singular}:#{action}:v1:#{path}" end |
Instance Method Details
#call ⇒ Object
20 21 22 23 |
# File 'lib/simple_crud/action_context.rb', line 20 def call controller.authenticate_user! if parameters[:authenticate] run end |