active_house 0.1.4 → 0.1.5

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: 1accc2700d5a5f68d28c6ee7a3c61edee951663a
4
- data.tar.gz: e3376ff0588800672aa83312f8d648f982bd7684
3
+ metadata.gz: 85e74ee14ef20d87860ffb175ba8adeef0488777
4
+ data.tar.gz: 226c0ae19eb0e1c451ac7bcbcfec035bbd602f16
5
5
  SHA512:
6
- metadata.gz: d75af3bdb4a7330bf48d0002babe1c9e807b4e359129ec9a9ca30557f2761c990d7ada2567fd5b756bd3d7bb1d47f1a11db9a456e73c02eec8d5aac319e96ba6
7
- data.tar.gz: 6ab03f7ce71326c65dd3d60173b93c5b02d6e427acd14d277ed0ca768ceb3960ea3edd60b695ae367c359c17fa516114e489197b957fb57468aa99d717da01bd
6
+ metadata.gz: aa2e80513b87275dd3996c09f6c6e63c7392fa0ab930468f1ec7fc08ae389b71d9be993cff385d1dcb6b5d98f056115dedbf1c0079164fe55dd807f1d0f09842
7
+ data.tar.gz: 35c22b8dc84e426b967a10169aa707979e3ed6a5ffb472c25c6092f4dccaadd384facc4c09de719e8e9fadafe29bfd3da9c3c7e8d458a06f571045497420d8ce
@@ -3,6 +3,7 @@ require_relative 'fromable'
3
3
  require_relative 'whereable'
4
4
  require_relative 'orderable'
5
5
  require_relative 'groupable'
6
+ require_relative 'limitable'
6
7
  require 'active_support/concern'
7
8
 
8
9
  module ActiveHouse
@@ -14,6 +15,7 @@ module ActiveHouse
14
15
  include ActiveHouse::Whereable
15
16
  include ActiveHouse::Orderable
16
17
  include ActiveHouse::Groupable
18
+ include ActiveHouse::Limitable
17
19
 
18
20
  included do
19
21
  protected
@@ -34,7 +36,8 @@ module ActiveHouse
34
36
  build_from_query_part,
35
37
  build_where_query_part,
36
38
  build_group_by_query_part,
37
- build_order_by_query_part
39
+ build_order_by_query_part,
40
+ build_limit_query_part
38
41
  ]
39
42
  end
40
43
 
@@ -86,7 +89,8 @@ module ActiveHouse
86
89
  select: :fields,
87
90
  where: :conditions,
88
91
  group_by: :grouping,
89
- order_by: :ordering
92
+ order_by: :ordering,
93
+ limit: :limit
90
94
  }
91
95
  end
92
96
 
@@ -1,4 +1,5 @@
1
1
  require 'active_support/concern'
2
+ require 'active_support/core_ext/string/filters'
2
3
 
3
4
  module ActiveHouse
4
5
  module Collectable
@@ -0,0 +1,27 @@
1
+ module ActiveHouse
2
+ module Limitable
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ private
7
+
8
+ def build_limit_query_part
9
+ return if @limit.empty?
10
+ if @limit[1]
11
+ "LIMIT #{@limit[0]}, #{@limit[1]}"
12
+ else
13
+ "LIMIT #{@limit[0]}"
14
+ end
15
+ end
16
+ end
17
+
18
+ def initialize(*)
19
+ @limit = []
20
+ super
21
+ end
22
+
23
+ def limit(limit_value, offset_value = nil)
24
+ chain_query limit: (@limit + [limit_value, offset_value]).uniq
25
+ end
26
+ end
27
+ end
@@ -11,7 +11,7 @@ module ActiveHouse
11
11
  end
12
12
 
13
13
  class_methods do
14
- delegate :to_a, :select, :where, :group_by, to: :all
14
+ delegate :to_a, :select, :where, :group_by, :limit, to: :all
15
15
 
16
16
  def all
17
17
  _query_class.new(self)
@@ -1,3 +1,3 @@
1
1
  module ActiveHouse
2
- VERSION = '0.1.4'.freeze
2
+ VERSION = '0.1.5'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_house
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Talakevich
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-23 00:00:00.000000000 Z
11
+ date: 2018-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -122,6 +122,7 @@ files:
122
122
  - lib/active_house/error.rb
123
123
  - lib/active_house/fromable.rb
124
124
  - lib/active_house/groupable.rb
125
+ - lib/active_house/limitable.rb
125
126
  - lib/active_house/logger.rb
126
127
  - lib/active_house/model.rb
127
128
  - lib/active_house/modeling.rb