horza 0.3.0 → 0.3.1

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: 2e84ae0d471c92bf87ccaa0894984e2eb1b874b3
4
- data.tar.gz: 82a91f1e8c57dfcef55e900824509357d28bd955
3
+ metadata.gz: d5bdfed1fbc5daf7a0e9e5ff11203ea7d156937b
4
+ data.tar.gz: da4e31d4c06cf95acdacc53b471337d1953f9805
5
5
  SHA512:
6
- metadata.gz: 4a9b216d669260c8bb880c5ee0bb97501a736709841cbffc05b34028f0e0b5f250b5eab7ef7205abdeb0c57d1df1c66b328313a6d899fd86e32f52b35a6660cb
7
- data.tar.gz: 06458d7480062e516133d9e0f557ec299c1cda2a936d040cf1f096a51cfe694a934138bd3f2912dd0fbad2aeae5b4242b22ec6a1f2233890aab4981246e929ba
6
+ metadata.gz: ed7eaf2d947317ce23752eec62b16d1186148cd6461f9f597bfda7fefca65a5bb173d454efe7ddd62fa49ecafcf1b84e958a641d09e79ad6c7028a67396c1897
7
+ data.tar.gz: 185a1dae46acca276649cf316faf1768ac412764958a6868bf822496ff78cf5b23032da51e4536114b9a1182743204f3f958e10ae5c53347814d1b33cd133729
data/README.md CHANGED
@@ -31,6 +31,20 @@ user.update!(options) # Update record - raise error on fail
31
31
  user.delete(options) # Delete record - return nil on fail
32
32
  user.delete!(options) # Delete record - raise error on fail
33
33
  user.association(target: :employer, via: []) # Traverse association
34
+
35
+ conditions = { last_name: 'Turner' }
36
+
37
+ # Ordering
38
+ user.find_all(conditions: conditions, order: { last_name: :desc })
39
+
40
+ # Limiting
41
+ user.find_all(conditions: conditions, limit: 20)
42
+
43
+ # Offset
44
+ user.find_all(conditions: conditions, offset: 50)
45
+
46
+ # Eager loading associations
47
+ employer.association(target: :users, eager_load: true)
34
48
  ```
35
49
 
36
50
  ## Options
@@ -38,7 +52,7 @@ user.association(target: :employer, via: []) # Traverse association
38
52
  **Base Options**
39
53
 
40
54
  Key | Type | Details
41
- ___ | ____ | _______
55
+ --- | ---- | -------
42
56
  `conditions` | Hash | Key value pairs for the query
43
57
  `order` | Hash | { `field` => `:asc`/`:desc` }
44
58
  `limit` | Integer | Number of records to return
@@ -50,27 +64,11 @@ ___ | ____ | _______
50
64
  **Association Options**
51
65
 
52
66
  Key | Type | Details
53
- ___ | ____ | _______
67
+ --- | ---- | -------
54
68
  `id` | Integer | The id of the root object
55
69
  `target` | Symbol | The target of the association - ie. employer.users would have a target of :users
56
70
  `eager_load` | Boolean | Whether to eager_load the association
57
71
 
58
- ```ruby
59
- conditions = { last_name: 'Turner' }
60
-
61
- # Ordering
62
- user.find_all(conditions: conditions, order: { last_name: :desc })
63
-
64
- # Limiting
65
- user.find_all(conditions: conditions, limit: 20)
66
-
67
- # Offset
68
- user.find_all(conditions: conditions, offset: 50)
69
-
70
- # Eager loading associations
71
- user.association(target: :sports_cars, via: [:employer], conditions: { make: 'Audi' }, eager_load: true)
72
- ```
73
-
74
72
  ## Outputs
75
73
 
76
74
  Horza queries return very dumb vanilla entities instead of ORM response objects.
@@ -30,7 +30,7 @@ module Horza
30
30
 
31
31
  def eager_args
32
32
  raise ::Horza::Errors::InvalidOption.new('You must pass eager_load: true and defined a target') unless eager_load? && target
33
- return target unless via
33
+ return target unless via && via.present?
34
34
 
35
35
  via.reverse.reduce({}) do |hash, table|
36
36
  if hash.empty?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: horza
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Turner