filterer 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 31f109e6bfe9ea0564189c48c3cea45762202cdc
4
- data.tar.gz: b0db1c21bb5cd14fe2672d294ee663bfc66a2886
3
+ metadata.gz: a5594041bdf01012c2ec2e828a7a553b1f211edd
4
+ data.tar.gz: 6ec0e36661c373bfba1f50fed9fe092c7bfea135
5
5
  SHA512:
6
- metadata.gz: ad5add521ba1b92b2fe624ee8c06062dd4596a5ae68ffc01b33e34982bd8b42fdd631594b10cab38677914c709992bfe39f4216d5839a18e1a6ba96f8ea7de1f
7
- data.tar.gz: 8af851433d0b36d46ba9bef2fd61d36baaf1cc25653485f0533d962760c653f06fa7573f9ef3187c5c17301be76c824828c17eb5b4e82c3d71ace4b3400321ee
6
+ metadata.gz: 639225bc7ff422f0079f829575d60d5baad174ec7a7a038385192a0bddde8fe51d37de3d10a1d63919c536fcb8f01f34bda502b2bf2ff2c2b9a7f46ed0d22d4e
7
+ data.tar.gz: 9ee0557b354736320cd1f7f0573464fa47cf1c1cdf775a2a3be44d50e0bdb4b7c8d0f257e06714bcad685dd153af355f4b11da622652965bf53aaaee996ca5aa
data/Rakefile CHANGED
@@ -4,21 +4,7 @@ rescue LoadError
4
4
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
5
  end
6
6
 
7
- require 'rdoc/task'
8
-
9
- RDoc::Task.new(:rdoc) do |rdoc|
10
- rdoc.rdoc_dir = 'rdoc'
11
- rdoc.title = 'Formbuilder'
12
- rdoc.options << '--line-numbers'
13
- rdoc.rdoc_files.include('README.rdoc')
14
- rdoc.rdoc_files.include('lib/**/*.rb')
15
- end
16
-
17
7
  APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
8
  load 'rails/tasks/engine.rake'
19
9
 
20
-
21
-
22
10
  Bundler::GemHelper.install_tasks
23
-
24
- require 'rake/testtask'
data/lib/filterer/base.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Filterer
2
2
  class Base
3
- IGNORED_PARAMS = [:page]
3
+ IGNORED_PARAMS = %w(page)
4
4
 
5
5
  attr_accessor :results, :meta, :direction, :sort, :params, :opts
6
6
 
@@ -54,8 +54,12 @@ module Filterer
54
54
  end
55
55
  end
56
56
 
57
+ def defaults
58
+ {}
59
+ end
60
+
57
61
  def initialize(params = {}, opts = {})
58
- @params, @opts = params, opts
62
+ @params, @opts = defaults.merge(params).with_indifferent_access, opts
59
63
  setup_meta
60
64
  find_results
61
65
  end
@@ -82,8 +86,9 @@ module Filterer
82
86
  def find_results
83
87
  @results = opts.delete(:starting_query) || starting_query
84
88
  add_params_to_query
85
- return if @opts[:chainable]
89
+ return if @opts[:chainable] && !@opts[:include_ordering]
86
90
  order_results
91
+ return if @opts[:chainable]
87
92
  add_meta
88
93
  return if @opts[:meta_only]
89
94
 
@@ -101,7 +106,7 @@ module Filterer
101
106
  end
102
107
 
103
108
  def add_params_to_query
104
- @params.reject { |k, v| k.in?(IGNORED_PARAMS) }
109
+ @params.reject { |k, v| k.to_s.in?(IGNORED_PARAMS) }
105
110
  .select { |k, v| v.present? }
106
111
  .each do |k, v|
107
112
 
@@ -1,3 +1,3 @@
1
1
  module Filterer
2
- VERSION = '0.4.1'
2
+ VERSION = '0.4.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filterer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Becker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-25 00:00:00.000000000 Z
11
+ date: 2015-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -137,12 +137,7 @@ dependencies:
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  description: Filterer lets your users easily filter results from your ActiveRecord
140
- models. What does that mean? Let's imagine a page in your application that lists
141
- the results of Person.all. What if you want to let your users filter the results
142
- by name? Or email? Or whether or not the Person is an admin? Where does that logic
143
- go? One answer could be your controller. That gets ugly fast. Another answer could
144
- be in your models. But passing a bunch of query parameters to a model isn't really
145
- a good practice either. Enter Filterer.
140
+ models.
146
141
  email:
147
142
  - adam@dobt.co
148
143
  executables: []