Class: SimpleCrud::ActionContext

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_crud/action_context.rb

Constant Summary collapse

DEFAULT_CACHE_TTL =
300

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#blockObject (readonly)

Returns the value of attribute block.



7
8
9
# File 'lib/simple_crud/action_context.rb', line 7

def block
  @block
end

#controllerObject (readonly)

Returns the value of attribute controller.



7
8
9
# File 'lib/simple_crud/action_context.rb', line 7

def controller
  @controller
end

#klassObject (readonly)

Returns the value of attribute klass.



7
8
9
# File 'lib/simple_crud/action_context.rb', line 7

def klass
  @klass
end

#parametersObject (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

#callObject



20
21
22
23
# File 'lib/simple_crud/action_context.rb', line 20

def call
  controller.authenticate_user! if parameters[:authenticate]
  run
end