Class: TableMe::UrlBuilder
- Inherits:
-
Object
- Object
- TableMe::UrlBuilder
- Defined in:
- lib/table_me/url_builder.rb
Overview
This class builds the url needed for the tables based on the table options. Some options are filtered out to make the url as short as possible.
Class Method Summary collapse
-
.filter_options(options) ⇒ Object
Filter out all options except name page search and order We need to dup the objects so we don’t alter the options object through out the table_me module.
- .url_for(options, additional_options = {}) ⇒ Object
Class Method Details
.filter_options(options) ⇒ Object
Filter out all options except name page search and order We need to dup the objects so we don’t alter the options object through out the table_me module
22 23 24 25 26 27 28 29 |
# File 'lib/table_me/url_builder.rb', line 22 def other_tables = [:other_tables].dup || [] = .dup .keep_if do |k,v| ['name','page','search','order'].include? k.to_s end other_tables << end |
.url_for(options, additional_options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/table_me/url_builder.rb', line 9 def url_for , = {} = .merge url = [] ().each do |option| url << {"tm_#{option[:name]}".to_sym => option }.to_param end "?#{url.join('&')}" end |