module SmartManaging::ControllerHelpers

Private Class Methods

included(c) click to toggle source
# File lib/smart_managing/controller_helpers.rb, line 14
def self.included(c)
  return unless c < ActionController::Base
  c.helper_method :manager, :smart_listing_resource,
    :smart_listing_collection
  c.include SmartListing::Helper::ControllerExtensions
  c.helper  SmartListing::Helper
  c.respond_to :html, :js
end

Public Instance Methods

index() click to toggle source
# File lib/smart_managing/controller_helpers.rb, line 4
def index
  smart_listing_create partial: 'list'
  respond_to do |format|
    format.html { render formats: :html }
    format.js { render formats: :js }
  end
end

Private Instance Methods

_prefixes() click to toggle source
Calls superclass method
# File lib/smart_managing/controller_helpers.rb, line 51
def _prefixes
  super << 'smart_managing'
end
build_resource_params() click to toggle source
# File lib/smart_managing/controller_helpers.rb, line 55
def build_resource_params
  parameters = params
  parameters = parameters.fetch(manager.model_sym, {})
  if parameters.respond_to?(:permit)
    [parameters.permit(manager.permitted_params)]
  else
    [parameters]
  end
end
custom_class() click to toggle source
# File lib/smart_managing/controller_helpers.rb, line 43
def custom_class
  custom_manager_name.constantize
end
custom_class?() click to toggle source
# File lib/smart_managing/controller_helpers.rb, line 39
def custom_class?
  Object.const_defined?(custom_manager_name)
end
custom_manager_name() click to toggle source
# File lib/smart_managing/controller_helpers.rb, line 47
def custom_manager_name
  "#{controller_name.classify}Manager"
end
manager() click to toggle source
# File lib/smart_managing/controller_helpers.rb, line 31
def manager
  @manager ||= manager_class.new(self)
end
manager_class() click to toggle source
# File lib/smart_managing/controller_helpers.rb, line 35
def manager_class
  custom_class? ? custom_class : SmartManaging::Base
end
smart_listing_collection() click to toggle source
# File lib/smart_managing/controller_helpers.rb, line 23
def smart_listing_collection
  collection
end
smart_listing_resource() click to toggle source
# File lib/smart_managing/controller_helpers.rb, line 27
def smart_listing_resource
  resource
end