Module: Deli::Helper::InstanceMethods

Defined in:
lib/deli/helper.rb

Instance Method Summary collapse

Instance Method Details

#deliObject

The query hash you want to use to paginate.



25
26
27
28
# File 'lib/deli/helper.rb', line 25

def deli
  @deli ||= deli_controller.render(query_params) if deli_controller.present?
  @deli
end

#deli_controllerObject



20
21
22
# File 'lib/deli/helper.rb', line 20

def deli_controller
  @deli_controller ||= self.is_a?(::ActionController::Base) ? self.class.query_controller : self.controller.class.query_controller
end

#deli_keysObject



48
49
50
# File 'lib/deli/helper.rb', line 48

def deli_keys
  deli_controller.keys
end

#param_operators(key) ⇒ Object



44
45
46
# File 'lib/deli/helper.rb', line 44

def param_operators(key)
  deli_controller.find(key).operators
end

#query_paramsObject

Simple method to give you the query parameters we’re interested in.



31
32
33
# File 'lib/deli/helper.rb', line 31

def query_params
  @query_params ||= ::Deli::Query.parse_query(request.query_string)
end

#queryable_keysObject



52
53
54
# File 'lib/deli/helper.rb', line 52

def queryable_keys
  deli_controller.keys - [:sort, :page, :limit]
end

#queryable_optionsObject



56
57
58
# File 'lib/deli/helper.rb', line 56

def queryable_options
  queryable_keys.map {|i| [i.titleize, i.to_s]}
end

#with_params(path, new_params = {}) ⇒ Object

with_params(admin_user_membership_path(@user, @membership), :sort => “name”) merges url with existing params



37
38
39
40
41
42
# File 'lib/deli/helper.rb', line 37

def with_params(path, new_params = {})
  params = query_params.merge(new_params.stringify_keys)
  return path if params.blank?
  query_string = ::Deli::Query.build_query(params)
  "#{path}?#{query_string}"
end