Class: Carnival::QueryForm

Inherits:
Object
  • Object
show all
Defined in:
app/models/carnival/query_form.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ QueryForm

Returns a new instance of QueryForm.



5
6
7
8
9
10
11
12
13
14
15
# File 'app/models/carnival/query_form.rb', line 5

def initialize(params)
  @scope = params[:scope]
  @search_term = params[:search_term]
  @advanced_search = params[:advanced_search]
  @date_period_label = params[:date_period_label]
  @date_period_from = params[:date_period_from]
  @date_period_to = params[:date_period_to]
  @sort_column = params[:sort_column]
  @sort_direction = params[:sort_direction]
  @page = params[:page]
end

Instance Attribute Details

#date_period_fromObject

Returns the value of attribute date_period_from.



3
4
5
# File 'app/models/carnival/query_form.rb', line 3

def date_period_from
  @date_period_from
end

#date_period_labelObject

Returns the value of attribute date_period_label.



3
4
5
# File 'app/models/carnival/query_form.rb', line 3

def date_period_label
  @date_period_label
end

#date_period_toObject

Returns the value of attribute date_period_to.



3
4
5
# File 'app/models/carnival/query_form.rb', line 3

def date_period_to
  @date_period_to
end

#scopeObject

Returns the value of attribute scope.



3
4
5
# File 'app/models/carnival/query_form.rb', line 3

def scope
  @scope
end

#search_termObject

Returns the value of attribute search_term.



3
4
5
# File 'app/models/carnival/query_form.rb', line 3

def search_term
  @search_term
end

#sort_columnObject

Returns the value of attribute sort_column.



3
4
5
# File 'app/models/carnival/query_form.rb', line 3

def sort_column
  @sort_column
end

#sort_directionObject

Returns the value of attribute sort_direction.



3
4
5
# File 'app/models/carnival/query_form.rb', line 3

def sort_direction
  @sort_direction
end

Instance Method Details

#advanced_searchObject



17
18
19
20
# File 'app/models/carnival/query_form.rb', line 17

def advanced_search
  return {} if @advanced_search.nil? 
  @advanced_search
end

#pageObject



31
32
33
34
# File 'app/models/carnival/query_form.rb', line 31

def page
  return 1 if @page.nil?
  @page.to_i
end

#to_hashObject



22
23
24
25
26
27
28
29
# File 'app/models/carnival/query_form.rb', line 22

def to_hash
  params = {} 
  self.instance_variables.each do |var|
    var_name = var.to_s.gsub('@', '')
    params[var_name] = self.send(var_name)
  end
  params
end