Class: CullenderController

Inherits:
Object
  • Object
show all
Includes:
Cullender::Controllers::ScopedViews
Defined in:
app/controllers/cullender_controller.rb

Overview

All Cullender controllers are inherited from here.

Direct Known Subclasses

Cullender::RulesController

Instance Method Summary collapse

Instance Method Details

#_prefixesObject

Override prefixes to consider the scoped view. Notice we need to check for the request due to a bug in Action Controller tests that forces _prefixes to be loaded before even having a request object.



42
43
44
45
46
47
48
# File 'app/controllers/cullender_controller.rb', line 42

def _prefixes #:nodoc:
  @_prefixes ||= if self.class.scoped_views? && request && cullender_mapping
    super.unshift("#{cullender_mapping.scoped_path}/#{controller_name}")
  else
    super
  end
end

#cullender_mappingObject

Attempt to find the mapped route for cullender based on request path



34
35
36
# File 'app/controllers/cullender_controller.rb', line 34

def cullender_mapping
  @cullender_mapping ||= request.env["cullender.mapping"]
end

#resourceObject

Gets the actual resource stored in the instance variable



14
15
16
# File 'app/controllers/cullender_controller.rb', line 14

def resource
  instance_variable_get(:"@#{resource_name}")
end

#resource_classObject

Proxy to cullender map class



25
26
27
# File 'app/controllers/cullender_controller.rb', line 25

def resource_class
  cullender_mapping.to
end

#resource_nameObject Also known as: scope_name

Proxy to cullender map name



19
20
21
# File 'app/controllers/cullender_controller.rb', line 19

def resource_name
  cullender_mapping.name
end

#resource_paramsObject



29
30
31
# File 'app/controllers/cullender_controller.rb', line 29

def resource_params
  params[resource_name]
end