Module: Puffer::Controller::Mutate

Extended by:
ActiveSupport::Concern
Defined in:
lib/puffer/controller/mutate.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#process_action(method_name, *args) ⇒ Object



13
14
15
16
# File 'lib/puffer/controller/mutate.rb', line 13

def process_action method_name, *args
  params[:puffer] = Rails.application.routes.resources_tree[params[:puffer]] if params[:puffer]
  super
end

#puffer_filtersObject



18
19
20
21
22
23
24
25
# File 'lib/puffer/controller/mutate.rb', line 18

def puffer_filters
  @puffer_filters ||= begin
    filters = params[Puffer::Filters.model_name.param_key] || {}
    filters.reverse_merge! :puffer_order => configuration.order if configuration.order.present?
    filters.reverse_merge! :puffer_per_page => configuration.per_page if configuration.per_page.present?
    Puffer::Filters.new filter_fields, filters
  end
end

#puffer_namespaceObject



27
28
29
# File 'lib/puffer/controller/mutate.rb', line 27

def puffer_namespace
  request.path_info.split('/').delete_if(&:blank?).first.to_sym
end

#recordObject



35
36
37
# File 'lib/puffer/controller/mutate.rb', line 35

def record
  @record || instance_variable_get("@#{resource.model_name}")
end

#recordsObject



39
40
41
# File 'lib/puffer/controller/mutate.rb', line 39

def records
  @records || instance_variable_get("@#{resource.model_name.pluralize}")
end

#resourceObject



31
32
33
# File 'lib/puffer/controller/mutate.rb', line 31

def resource
  @resource ||= Puffer::Resource.new params, self
end