Class: Stattleship::Params::QueryParams

Inherits:
Object
  • Object
show all
Defined in:
lib/stattleship/params/query_params.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pageObject

Returns the value of attribute page


4
5
6
# File 'lib/stattleship/params/query_params.rb', line 4

def page
  @page
end

#per_pageObject

Returns the value of attribute per_page


4
5
6
# File 'lib/stattleship/params/query_params.rb', line 4

def per_page
  @per_page
end

#season_idObject

Returns the value of attribute season_id


4
5
6
# File 'lib/stattleship/params/query_params.rb', line 4

def season_id
  @season_id
end

Instance Method Details

#paramsObject


6
7
8
9
10
11
12
# File 'lib/stattleship/params/query_params.rb', line 6

def params
  {
    'page' => page,
    'per_page' => per_page,
    'season_id' => season_id,
  }
end

#queryObject


14
15
16
# File 'lib/stattleship/params/query_params.rb', line 14

def query
  { 'query' => validate }
end

#validateObject


18
19
20
21
22
23
24
25
26
27
# File 'lib/stattleship/params/query_params.rb', line 18

def validate
  query_parameters.keys.each do |key|
    validator(key).new(key: key,
                       params: query_parameters,
                       class_name: self.class.name).
      validate
  end

  query_parameters
end