activerecord-extensions 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 953348905dd5de570ad386a3bbdb8cf7dafef919
4
+ data.tar.gz: 154fc5d1b348d9a43de8ef362b257c993b625823
5
+ SHA512:
6
+ metadata.gz: f4a6faf6814c687ee56d510460368f4b72b6c293caab12899afc9dd99ff3146d38fa340972b8000c62b507ea815d6e75fb4986dc82ee573d53abbf0f188bde2f
7
+ data.tar.gz: 8979d07045ca2f1a3c1fdee00a560d357ab6178504aa2ae1fd8db2652fdbe5db7d7e215cd08883afca60eb79aca1db54bdd89f41ab1e6a550a7fb5ad12373e91
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Faisal Mansoor
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ ## activerecord-extensions
2
+
3
+ Misc activerecord extensions
4
+
5
+ ## Installation
6
+
7
+ `gem install activerecord-extensions`
8
+
9
+ ## Usage
10
+
11
+ ```ruby
12
+ require 'activerecord-extensions'
13
+ ```
14
+
15
+ ### ActiveRecord::Base helper
16
+
17
+
18
+ ## Requirements
19
+
20
+ Requires ActiveRecord = 4.2.4, tested with Ruby 2.2.0.
21
+
22
+ ## Running Tests
23
+
24
+ `bundle exec rspec`
25
+
26
+ ## Authors
27
+
28
+ * Faisal Mansoor http://github.com/faisalmansoor
@@ -0,0 +1,7 @@
1
+ require 'active_record'
2
+ require 'activerecord-extensions/extensions/query_methods'
3
+
4
+ module ActiverecordExtensions
5
+ autoload :QueryBuilder, 'activerecord-extensions/query_builder'
6
+ end
7
+
@@ -0,0 +1,8 @@
1
+ ActiveRecord::QueryMethods.module_eval do
2
+ def bind_parameters(opts)
3
+ opts = ActiveRecord::PredicateBuilder.resolve_column_aliases(klass, opts)
4
+ _, bind_values = create_binds(opts)
5
+ self.bind_values += bind_values
6
+ self
7
+ end
8
+ end
@@ -0,0 +1,18 @@
1
+ module ActiverecordExtensions
2
+ module QueryBuilder
3
+
4
+ def where_gt(attribute, value)
5
+ where_with_bind(arel_table[attribute].gt(Arel::Nodes::BindParam.new), attribute, value)
6
+ end
7
+
8
+ def where_lt(attribute, value)
9
+ where_with_bind(arel_table[attribute].lt(Arel::Nodes::BindParam.new), attribute, value)
10
+ end
11
+
12
+ private
13
+ def where_with_bind(clause, attribute, value)
14
+ where(clause).bind_parameters({attribute => value})
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ module ActiverecordExtensions
2
+ VERSION = '0.1.1'
3
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activerecord-extensions
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Faisal Mansoor
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-10-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 4.2.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 4.2.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5'
33
+ description: Tools to help parametrize queries.
34
+ email:
35
+ - faisal.mansoor@gmail.com
36
+ executables: []
37
+ extensions: []
38
+ extra_rdoc_files: []
39
+ files:
40
+ - LICENSE
41
+ - README.md
42
+ - lib/activerecord-extensions.rb
43
+ - lib/activerecord-extensions/extensions/query_methods.rb
44
+ - lib/activerecord-extensions/query_builder.rb
45
+ - lib/activerecord-extensions/version.rb
46
+ homepage: http://github.com/faisalmansoor
47
+ licenses:
48
+ - MIT
49
+ metadata: {}
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubyforge_project:
66
+ rubygems_version: 2.4.5
67
+ signing_key:
68
+ specification_version: 4
69
+ summary: Tools to help parametrize queries.
70
+ test_files: []